User:Veko/common.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | The accompanying .css page for this skin can be added at User:Veko/common.css. |
// Enable caching for resource loads
if(!/\bnocache=\b/.test(location.href)){
let e=(e,t,n)=>(e=e.replace(/special:mypage/i,"User:"+mw.config.get("wgUserName")),
$.get("https://"+t+"/w/api.php?titles="+e+"&origin=*&format=json&formatversion=2&uselang=content&maxage=86400&smaxage=86400&action=query&prop=revisions|info&rvprop=content&rvlimit=1")
.then((r=>{let o=r.query.pages[0];if(o.missing)return;let a=o.revisions[0].content;
if(n&&"text/javascript"!==n||"javascript"!==o.contentmodel){
if("text/css"!==n||"css"!==o.contentmodel)return $.Deferred().reject('Refused to load "'+e+'"@'+t+": content type mismatch");
mw.loader.addStyleTag(a)
}else{let e=document.createElement("script");e.innerHTML=a,document.head.appendChild(e)}}))),
t=e=>{let t=/^(?:(?:https:)?\/\/(.*))?\/w\/index.php/.exec(e),
n=/\btitle=([^=?&]*)/.exec(e);return t&&n&&/\baction=raw\b/.test(e)&&/\bctype=/.test(e)?[n[1],t[1]||mw.config.get("wgServerName")]:null};
window.importScript=t=>{e(encodeURIComponent(t),mw.config.get("wgServerName"),"text/javascript")},
window.importStyleSheet=t=>{e(encodeURIComponent(t),mw.config.get("wgServerName"),"text/css")};
let n=mw.loader.load;
mw.loader.load=function(r,o){let a=t(r);a?e(a[0],a[1],o):n.apply(mw.loader,[...arguments])};
let r=mw.loader.getScript;
mw.loader.getScript=function(n){let o=t(n);return o?e(o[0],o[1],"text/javascript"):r.apply(mw.loader,[...arguments])}
}
// Useful scripts
importScript('User:RedWarn/.js'); // Backlink: [[User:RedWarn/.js]]
importScript('User:Ingenuity/AntiVandal.js'); // Backlink: [[User:Ingenuity/AntiVandal.js]]
importScript('User:Awesome Aasim/rcpatrol.js'); // Backlink: [[User:Awesome Aasim/rcpatrol.js]]
importScript('User:Evad37/rater.js'); // Backlink: [[User:Evad37/rater.js]]
importScript('User:Qwertyytrewqqwerty/DisamAssist.js'); // Backlink: [[User:Qwertyytrewqqwerty/DisamAssist.js]]
importScript('User:Jackmcbarn/editProtectedHelper.js'); // Backlink: [[User:Jackmcbarn/editProtectedHelper.js]]
importScript('User:Evad37/duplinks-alt.js'); // Backlink: [[User:Evad37/duplinks-alt.js]]
importScript('User:GoldenRing/wordcount.js'); // Backlink: [[User:GoldenRing/wordcount.js]]
importScript('User:Ohconfucius/script/Common Terms.js'); // Backlink: [[User:Ohconfucius/script/Common Terms.js]]
importScript('User:Evad37/Thanky.js'); // Backlink: [[User:Evad37/Thanky.js]]
importScript('User:Headbomb/unreliable.js'); // Backlink: [[User:Headbomb/unreliable.js]]
importScript('User:Enterprisey/cv-revdel.js'); // Backlink: [[User:Enterprisey/cv-revdel.js]]
//importScript('User:MusikAnimal/responseHelper.js'); // Backlink: [[User:MusikAnimal/responseHelper.js]]
importScript('User:SD0001/StubSorter.js'); // Backlink: [[User:SD0001/StubSorter.js]]
importScript('User:Awesome Aasim/xfdvote.js'); // Backlink: [[User:Awesome Aasim/xfdvote.js]]
importScript('User:Mr. Stradivarius/gadgets/Draftify.js'); // Backlink: [[User:Mr. Stradivarius/gadgets/Draftify.js]]
importScript('User:Eejit43/scripts/rmtr-helper.js'); // Backlink: [[User:Eejit43/scripts/rmtr-helper.js]]
importScript('User:MPGuy2824/MoveToDraft.js'); // Backlink: [[User:MPGuy2824/MoveToDraft.js]]
importScript('User:Eejit43/scripts/redirect-helper.js'); // Backlink: [[User:Eejit43/scripts/redirect-helper.js]]
importScript('User:Bradv/Scripts/Superlinks.js'); // Backlink: [[User:Bradv/Scripts/Superlinks.js]]
importScript('User:SD0001/GAN-helper.js'); // Backlink: [[User:SD0001/GAN-helper.js]]
importScript('User:Novem Linguae/Scripts/GANReviewTool.js'); // Backlink: [[User:Novem Linguae/Scripts/GANReviewTool.js]]
importScript('User:The Earwig/copyvios.js'); // Backlink: [[User:The Earwig/copyvios.js]]
importScript('User:Xenocidic/statusChanger2.js'); // Backlink: [[User:Xenocidic/statusChanger2.js]]
importScript('User:DannyS712/Draft no cat.js'); // Backlink: [[User:DannyS712/Draft no cat.js]]
importScript('User:BrandonXLF/ReferenceExpander.js'); // Backlink: [[User:BrandonXLF/ReferenceExpander.js]]
importScript('User:Awesome Aasim/redirectcreator.js'); // Backlink: [[User:Awesome Aasim/redirectcreator.js]]
importScript('User:Qwerfjkl/scripts/CFDlister.js'); // Backlink: [[User:Qwerfjkl/scripts/CFDlister.js]]
importScript('User:Shubinator/DYKcheck.js'); // Backlink: [[User:Shubinator/DYKcheck.js]]
importScript('User:BrandonXLF/HotDefaultSort.js'); // Backlink: [[User:BrandonXLF/HotDefaultSort.js]]
importScript('User:Theleekycauldron/DYK_promoter.js'); // Backlink: [[User:Theleekycauldron/DYK_promoter.js]]
importScript('User:BrandonXLF/CollapseSections.js'); // Backlink: [[User:BrandonXLF/CollapseSections.js]]
importScript('User:Schminnte/PageCuration.js'); // Backlink: [[User:Schminnte/PageCuration.js]]
importScript('User:Nardog/CatChangesViewer.js'); // Backlink: [[User:Nardog/CatChangesViewer.js]]
importScript('User:קיפודנחש/cat-a-lot.js'); // Backlink: [[User:קיפודנחש/cat-a-lot.js]]
importScript('User:Enterprisey/orcp-helper.js'); // Backlink: [[User:Enterprisey/orcp-helper.js]]
importScript('User:Novem Linguae/Scripts/DontForgetG12.js'); // Backlink: [[User:Novem Linguae/Scripts/DontForgetG12.js]]
importScript('User:Writ Keeper/rollbackSummary.js'); // Backlink: [[User:Writ Keeper/rollbackSummary.js]]
importScript('User:BrandonXLF/CitationStyleMarker.js'); // Backlink: [[User:BrandonXLF/CitationStyleMarker.js]]
importScript('User:Andrybak/Archiver.js'); // Backlink: [[User:Andrybak/Archiver.js]]
importScript('User:PleaseStand/segregate-refs.js'); // Backlink: [[User:PleaseStand/segregate-refs.js]]
importScript('User:Ohconfucius/script/MOSNUM dates.js'); // Backlink: [[User:Ohconfucius/script/MOSNUM dates.js]]
importScript('User:JPxG/Difformatter.js'); // Backlink: [[User:JPxG/Difformatter.js]]
importScript('User:Qwerfjkl/scripts/editRedirect.js'); // Backlink: [[User:Qwerfjkl/scripts/editRedirect.js]]
importScript('User:Enterprisey/section-redir-note.js'); // Backlink: [[User:Enterprisey/section-redir-note.js]]
importScript('User:BrandonXLF/ShowUserGender.js'); // Backlink: [[User:BrandonXLF/ShowUserGender.js]]
importScript('User:Novem_Linguae/Scripts/VisualEditorEverywhere.js'); // Backlink: [[User:Novem_Linguae/Scripts/VisualEditorEverywhere.js]]
importScript('User:Ingenuity/MergeDuplicateRefs.js'); // Backlink: [[User:Ingenuity/MergeDuplicateRefs.js]]
importScript('User:Sohom_Datta/fastreview.js'); // Backlink: [[User:Sohom_Datta/fastreview.js]]
importScript('User:Nardog/RefRenamer.js'); // Backlink: [[User:Nardog/RefRenamer.js]]
importScript('User:Nardog/MoveHistory.js'); // Backlink: [[User:Nardog/MoveHistory.js]]
importScript('User:Trappist the monk/HarvErrors.js'); // Backlink: [[User:Trappist the monk/HarvErrors.js]]
importScript('User:Polygnotus/DuplicateReferences.js'); // Backlink: [[User:Polygnotus/DuplicateReferences.js]]
// Add "back to top" links to each section
$(function () {
var elems = document.getElementsByClassName('editsection');
for (let i = 0; i < elems.length; i++) {
var span = document.createElement('span');
var link = document.createElement('a');
link.href = '#top';
link.appendChild(document.createTextNode('back to top'));
span.appendChild(document.createTextNode('['));
span.appendChild(link);
span.appendChild(document.createTextNode('] '));
elems[i].insertBefore(span, elems[i].firstChild);
}
});
// ORES Article Quality Predictor
$.getScript(
'//meta.wikimedia.org/w/index.php?title=User:EpochFail/ArticleQuality-system.js&action=raw&ctype=text/javascript',
function () {
articleQuality = new ArticleQuality({
ores_host: "https://ores.wikimedia.org",
weights: {
Stub: 1,
Start: 2,
C: 3,
B: 4,
GA: 5,
FA: 6
},
names: {
Stub: "{{icon|Stub}}",
Start: "{{icon|Start}}",
C: "{{icon|C}}",
B: "{{icon|B}}",
GA: "{{icon|GA}}",
FA: "{{icon|FA}}"
},
assessment_system: "Pseudoscience",
dbname: "enwiki"
});
if (mw.config.get('wgAction') === "view" &&
(mw.config.get('wgNamespaceNumber') === 0 ||
mw.config.get('wgNamespaceNumber') === 2 ||
mw.config.get('wgNamespaceNumber') === 118)) {
articleQuality.getAndRenderScoreHeader();
}
articleQuality.addScoresToArticleLinks();
}
);
mw.loader.load('//meta.wikimedia.org/w/index.php?title=User%3AEpochFail%2FArticleQuality.css&action=raw&ctype=text/javascript');
importScript('User:DreamRimmer/User not around.js'); // Backlink: [[User:DreamRimmer/User not around.js]]
importScript('User:DreamRimmer/EasySubpage.js'); // Backlink: [[User:DreamRimmer/EasySubpage.js]]
mw.loader.using(['jquery', 'mediawiki.util']).then(function () {
(function () {
if (mw.config.get("wgDBname") !== "enwiki") return;
let seen = new Set();
let count = 0;
const baseInterval = 30000; // 30s
const minDelay = 5000; // min 5s delay between checks
// Create notification bell and dropdown
const notifContainer = $('<div>')
.css({
position: "fixed",
top: "0.5em",
right: "3em",
zIndex: 9999,
fontFamily: "sans-serif"
});
const notifIcon = $('<span>')
.text("🔔")
.css({
cursor: "pointer",
fontSize: "16px",
background: "#fff",
border: "1px solid #ccc",
borderRadius: "50%",
padding: "4px 8px",
fontWeight: "bold",
position: "relative",
boxShadow: "0 1px 4px rgba(0,0,0,0.1)"
});
const notifCount = $('<span>')
.text("0")
.css({
position: "absolute",
top: "-6px",
right: "-6px",
background: "#d33",
color: "#fff",
borderRadius: "50%",
padding: "2px 6px",
fontSize: "10px",
display: "none"
});
const notifDropdown = $('<div>')
.css({
display: "none",
position: "absolute",
top: "30px",
right: "0",
width: "320px",
maxHeight: "400px",
overflowY: "auto",
background: "#fff",
border: "1px solid #ccc",
borderRadius: "6px",
boxShadow: "0 4px 12px rgba(0,0,0,0.15)",
padding: "10px"
});
notifIcon.on("click", function () {
notifDropdown.toggle();
});
notifIcon.append(notifCount);
notifContainer.append(notifIcon).append(notifDropdown);
$("body").append(notifContainer);
async function checkPending() {
const start = performance.now();
const url = "https://en.wikipedia.org/w/api.php?action=query&list=recentchanges&rcprop=title|ids|tags&rclimit=50&rcshow=!bot&format=json&origin=*";
try {
const res = await fetch(url);
const data = await res.json();
const changes = data?.query?.recentchanges || [];
for (const change of changes) {
if (change.tags.includes("flaggedrevs-pending") && !seen.has(change.revid)) {
seen.add(change.revid);
count++;
const pageTitle = change.title;
const pageUrl = `https://en.wikipedia.org/wiki/${encodeURIComponent(pageTitle.replace(/ /g, "_"))}`;
notifDropdown.prepend(
$("<div>")
.css({
marginBottom: "8px",
paddingBottom: "8px",
borderBottom: "1px solid #eee"
})
.append(
$("<a>")
.attr("href", pageUrl)
.attr("target", "_blank")
.text(pageTitle)
.css({ fontWeight: "bold", color: "#0645ad" })
)
);
notifCount.text(count).show();
mw.notify(
$("<a>")
.attr("href", pageUrl)
.attr("target", "_blank")
.text("Pending: " + pageTitle)[0],
{
title: "Pending Change Alert",
autoHide: false
}
);
}
}
} catch (e) {
console.error("Pending changes check failed:", e);
} finally {
const duration = performance.now() - start;
const delay = Math.max(minDelay, baseInterval - duration);
setTimeout(checkPending, delay);
}
}
checkPending();
})();
});