Jump to content

User:Veko/common.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Veko (talk | contribs) at 00:10, 9 April 2025 (+-). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// 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 for rollback/EC/PCR rights
importScript('User:SD0001/BDCS.js');
importScript('User:RedWarn/.js');
importScript('User:Ingenuity/AntiVandal.js');
importScript('User:Awesome Aasim/rcpatrol.js');
importScript('User:Evad37/rater.js');
importScript('User:Qwertyytrewqqwerty/DisamAssist.js');
importScript('User:Jackmcbarn/editProtectedHelper.js');
importScript('User:Evad37/duplinks-alt.js');
importScript('User:GoldenRing/wordcount.js');
importScript('User:Ohconfucius/script/Common Terms.js');
importScript('User:Evad37/Thanky.js');
importScript('User:Headbomb/unreliable.js');
importScript('User:Enterprisey/cv-revdel.js');
importScript('User:MusikAnimal/responseHelper.js');
importScript('User:SD0001/StubSorter.js');
importScript('User:Awesome Aasim/xfdvote.js');
importScript('User:Mr. Stradivarius/gadgets/Draftify.js');
importScript('User:Eejit43/scripts/rmtr-helper.js');
importScript('User:MPGuy2824/MoveToDraft.js');
importScript('User:Eejit43/scripts/redirect-helper.js');
importScript('User:Bradv/Scripts/Superlinks.js');
importScript('User:SD0001/GAN-helper.js');
importScript('User:Novem Linguae/Scripts/GANReviewTool.js');
importScript('User:The Earwig/copyvios.js');
importScript('User:Xenocidic/statusChanger2.js');
importScript('User:DannyS712/Draft no cat.js');
importScript('User:BrandonXLF/ReferenceExpander.js');
importScript('User:Awesome Aasim/redirectcreator.js');
importScript('User:Qwerfjkl/scripts/CFDlister.js');
importScript('User:Shubinator/DYKcheck.js');
importScript('User:BrandonXLF/HotDefaultSort.js');
importScript('User:Theleekycauldron/DYK_promoter.js');
importScript('User:BrandonXLF/CollapseSections.js');
importScript('User:Schminnte/PageCuration.js');
importScript('User:Nardog/CatChangesViewer.js');
importScript('User:קיפודנחש/cat-a-lot.js');
importScript('User:Enterprisey/orcp-helper.js');
importScript('User:Novem Linguae/Scripts/DontForgetG12.js');
importScript('User:Writ Keeper/rollbackSummary.js');
importScript('User:BrandonXLF/CitationStyleMarker.js');
importScript('User:Andrybak/Archiver.js');
importScript('User:PleaseStand/segregate-refs.js');
importScript('User:Ohconfucius/script/MOSNUM dates.js');
importScript('User:JPxG/Difformatter.js');
importScript('User:Qwerfjkl/scripts/editRedirect.js');
importScript('User:Enterprisey/section-redir-note.js');
importScript('User:BrandonXLF/ShowUserGender.js');
importScript('User:Novem_Linguae/Scripts/VisualEditorEverywhere.js');
importScript('User:Ingenuity/MergeDuplicateRefs.js');
importScript('User:Sohom_Datta/fastreview.js');
importScript('User:Nardog/RefRenamer.js');
importScript('User:Nardog/MoveHistory.js');
importScript('User:Trappist the monk/HarvErrors.js');
importScript('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:EpochFail/ArticleQuality.css&action=raw&ctype=text/javascript');