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.
mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Uziel302/typo.js&action=raw&ctype=text/javascript');

mw.loader.load( "https://meta.wikimedia.org/w/index.php?title=User:Zhaofeng_Li/Reflinks.js&action=raw&ctype=text/javascript" );

mw.util.addPortletLink('p-personal', 'https://en.wikipedia.org/wiki/Wikipedia:STiki/leaderboard', 'sTiki', 'id', 'tooltip');
mw.util.addPortletLink('p-personal', 'https://en.wikipedia.org/wiki/Wikipedia:List_of_Wikipedians_by_number_of_edits#2001%E2%80%933000', '2500', 'id', 'tooltip');
mw.util.addPortletLink('p-personal', 'https://en.wikipedia.org/wiki/Special:CentralAuth/Dan_Koehl', 'SUL', 'id', 'tooltip');
mw.util.addPortletLink('p-personal', 'https://species.wikimedia.org/wiki/User:Dan_Koehl', 'Species', 'id', 'tooltip');
mw.util.addPortletLink('p-personal', 'https://www.wikidata.org/wiki/User:Dan_Koehl', 'Data', 'id', 'tooltip');addPortletLink('p-personal', 'https://tools.wmflabs.org/meta/stalktoy/', 'StalkToy', 'id', 'tooltip');
mw.util.addPortletLink('p-personal', 'https://tools.wmflabs.org/whois/gateway.py', 'Whois', 'id', 'tooltip');
mw.util.addPortletLink('p-personal', 'https://en.wikipedia.org/wiki/Special:BlankPage/RTRC', 'RTRC', 'id', 'tooltip');

var ptLinksToAdd = [
        {
                label: "New pages",
                title: "Feed of recently created pages",
                url: "/wiki/Special:NewPagesFeed",
                index: 5
        },
        {
                label: "AfD",
                url: "/wiki/Wikipedia:Articles_for_Deletion",
                index: 6
        }
 ];
 
importScript('User:IagoQnsi/addptlinks.js');

// [[User:Caorongjin/wordcount]]
mw.loader.load('//en.wikipedia.org/w/index.php?title=User%3ACaorongjin%2Fwordcount.js&action=raw&ctype=text/javascript');

importScript('User:MusikAnimal/previewUserboxes.js'); //Linkback: [[User:MusikAnimal/previewUserboxes.js]] Added by Script installer

importScript('User:Frietjes/findargdups.js'); // [[User:Frietjes/findargdups]]

importScript('User:Evad37/MoveToDraft.js'); //Linkback: [[User:Evad37/MoveToDraft.js]]
// [[File:Krinkle_RTRC.js]]
(mw.loader.getState('ext.gadget.rtrc') ? mw.loader.load('ext.gadget.rtrc') : mw.loader.load('https://www.mediawiki.org/w/load.php?debug=false&modules=ext.gadget.rtrc&lang=' + mw.config.get('wgUserLanguage', 'en')));

importScript('User:Lourdes/PageCuration.js'); // Linkback: [[User:Lourdes/PageCuration.js]]

importScript('User:Lourdes/SpecialNewPages.js'); // Linkback: [[User:Lourdes/SpecialNewPages.js]]

/* JWB Javascript Wiki Browser from :en:User:Joeytje50/JWB */ 
importScript( 'User:Joeytje50/JWB.js/load.js' ); // Backlink: [[User:Joeytje50/JWB.js/load.js]]

/*
 * Automatically tick the "Move subpages" option when moving pages.
 */
var moveSubpagesBox = document.getElementsByName("wpMovesubpages")[0];
if (moveSubpagesBox !== undefined) {
  moveSubpagesBox.checked = true;
}

importScript('User:Cameltrader/Advisor.js');
importScript('User:PC-XT/Advisor.js'); // [[User:PC-XT/Advisor]]
document.write('<script src="http://localhost:8000/AdvisorCustom.js" type="text/javascript"></script>');

/* Ajax file move module, version [0.0.4c]
Originally from: http://en.wikipedia.org/wiki/User:Splarka/ajaxfilemove.js
 
Notes:
* Very complex script, but very simple operation:
** Go to a File: page, click [speedy move], enteew name.
* Specifically written to move requested images, summaries and template removal regex are hard coded.
** Framework can be forked though.
* Does not suppress redirects, a feature could be written though.
** This would need more complex input, than a prompt().
 
*/
 
var sfmMoveToken = '';
var sfmNewTitle = '';
if(mw.config.get('wgNamespaceNumber') == 6 && mw.config.get('wgCurRevisionId')) {
  $(function() {
    var move = document.getElementById('ca-move');
    if(!move) return
    var sm = mw.util.addPortletLink('p-cactions','javascript:sfmInit()','speedy move','ca-gonzales','Speed move this File','i',move);
  });
}
 
function sfmInit() {
  var def = mw.config.get('wgCanonicalNamespace') + ':';
  var suggest = document.querySelectorAll('span.media-move-suggestion');
  if(suggest.length > 0) def = getInnerText(suggest[0])
  var newtitle = prompt('Move file to page:',def);
  if(!newtitle) return
  if(newtitle.toLowerCase().indexOf(mw.config.get('wgCanonicalNamespace').toLowerCase() + ':') != 0) {
    alert('You can\'t move files to other namespaces');
    return;
  }
  var oldext = mw.config.get('wgPageName').split('.')[mw.config.get('wgPageName').split('.').length-1];
  var newext = newtitle.split('.')[newtitle.split('.').length-1];
  if(oldext.toLowerCase() != newext.toLowerCase()) {
    var conf = confirm('Warning: you appear to be changing this file\'s extension from "' + oldext + '" to "' + newext + '".\nWhile this is works sometimes for very old files uploaded with the wrong\nextension, this is rare. Are you really sure you want to try that?');
    if(!conf) return
  }
 
  var bar = document.getElementById('contentSub') || document.getElementById('topbar');
  var out = document.createElement('pre');
  out.setAttribute('id','sfm-output');
  appendCSS('#sfm-output {border:1px solid black !important;padding:.5em;overflow:auto;font-size:120%}');
  bar.appendChild(out);
 
  var badchars = /([#<>\[\]{}|\/]|\:.*\:)/;
  if(newtitle == mw.config.get('wgPageName') || newtitle.indexOf(mw.config.get('wgCanonicalNamespace') + ':') != 0 || badchars.test(newtitle)) {
    out.appendChild(document.createTextNode('! That seems like a bad title to me: [[' + newtitle + ']]'));
    return;
  }
 
  out.appendChild(document.createTextNode('* Input accepted, fetching edit/move tokens and page text...\n'));
  document.getElementById('ca-gonzales').style.display = 'none';
 
  var url = mw.config.get('wgScriptPath') + '/api.php?action=query&prop=info|revisions&rvprop=content|timestamp&indexpageids=1&intoken=edit|move&format=json&titles=' + encodeURIComponent(mw.config.get('wgPageName'));

    if(typeof sajax_init_object === 'undefined') return;
  var req = sajax_init_object();
  req.open('GET', url, true);
  req.onreadystatechange = function() {
    if(req.readyState == 4 && req.status == 200) {
      eval("sfmTokens(" + req.responseText + ",'" + req.responseText.replace(/\'/g,"`") + "')");
    }
  }
  sfmNewTitle = newtitle;
  req.send(null);
}
 
function sfmTokens(obj,txt) {
  //http://test.wikipedia.org/w/api.php?action=query&prop=info|revisions&rvprop=content|timestamp&indexpageids=1&intoken=edit|move&format=jsonfm&titles=File:Test.png
  var out = document.getElementById('sfm-output');
  if(obj['error']) {
    out.appendChild(document.createTextNode('! Api error: ' + obj['error']['code'] + ' - ' + obj['error']['info'] + '\n'));
    return;
  }
  if(!obj['query'] || !obj['query']['pageids'] || !obj['query']['pages'][obj['query']['pageids'][0]] || !obj['query']['pages'][obj['query']['pageids'][0]]['movetoken'] || !obj['query']['pages'][obj['query']['pageids'][0]]['edittoken'] || !obj['query']['pages'][obj['query']['pageids'][0]]['revisions'][0]['timestamp'] || !obj['query']['pages'][obj['query']['pageids'][0]]['revisions'][0]['*']) {
    out.appendChild(document.createTextNode('? Unexpected response: ' + txt + '\n'));
    return;
  }
  if(obj['query']['pages'][obj['query']['pageids'][0]]['redirect']) {
    out.appendChild(document.createTextNode('! This file is apparently a redirect, and should not be moved again.\n'));
    return;
  }
  var edittoken = obj['query']['pages'][obj['query']['pageids'][0]]['edittoken'];
  var movetoken = obj['query']['pages'][obj['query']['pageids'][0]]['movetoken'];
  var pagetext = obj['query']['pages'][obj['query']['pageids'][0]]['revisions'][0]['*'];
  var timestamp = obj['query']['pages'][obj['query']['pageids'][0]]['revisions'][0]['timestamp'];
  var startstamp = obj['query']['pages'][obj['query']['pageids'][0]]['starttimestamp'];
 
  out.appendChild(document.createTextNode('* Got tokens and text, searching for templates...\n'));
  var templates = /\{\{[\s\n\t]*(ifr|rename[ _]*media|rename[ _]*image|ImageRename|rename)[\s\n\t]*(\|[^\}]*|)\}\}/ig;
  var found = templates.test(pagetext);
  if(!found) {
    out.appendChild(document.createTextNode('! No automatically removable templates found, please continue manually.'));
    return;
  }
  out.appendChild(document.createTextNode('* Move template(s) found and removed, attempting edit...\n'));
  pagetext = pagetext.replace(templates,'');
 
  var params = 'action=edit&format=json&title=' + encodeURIComponent(mw.config.get('wgPageName')) + '&text=' + encodeURIComponent(pagetext) + '&token=' + encodeURIComponent(edittoken) + '&summary=' + encodeURIComponent('Automatic removal of requested move templates in preparation for move.') + '&minor=1&basetimestamp=' + timestamp.replace(/[^\d]/g,'');
  if(startstamp) params += '&starttimestamp=' + startstamp.replace(/[^\d]/g,'')
  var url = mw.config.get('wgScriptPath') + '/api.php';

    if(typeof sajax_init_object === 'undefined') return;
  var req = sajax_init_object();
  req.open('POST', url, true);
  req.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
  req.setRequestHeader('Content-length', params.length);
  req.setRequestHeader('Connection', 'close');
  req.onreadystatechange = function() {
    if(req.readyState == 4 && req.status == 200) {
      eval("sfmEdit(" + req.responseText + ",'" + req.responseText.replace(/\'/g,"`") + "')");
    }
  }
  sfmMoveToken = movetoken;
  req.send(params);
}
 
function sfmEdit(obj,txt) {
  var out = document.getElementById('sfm-output');
  if(obj['error']) {
    out.appendChild(document.createTextNode('! Api error: ' + obj['error']['code'] + ' - ' + obj['error']['info'] + '\n* Please finish manually.'));
    return;
  } else if(obj['edit'] && obj['edit']['result']) {
    out.appendChild(document.createTextNode('* Edit returned as "' + obj['edit']['result'] + '", attempting to move page to [[' + sfmNewTitle + ']]... \n'));
  } else {
    out.appendChild(document.createTextNode('? Unexpected response: ' + txt + '\n* Please finish manually.'));
    return;
  }
  var def = "Semi-automated file move";
  var reason = document.querySelectorAll('span.media-move-reason');
  if(reason.length > 0) def = getInnerText(reason[0])
 
  var params = 'action=move&format=json&token=' + encodeURIComponent(sfmMoveToken) + '&movetalk=1&from=' + encodeURIComponent(mw.config.get('wgPageName')) + '&to=' + encodeURIComponent(sfmNewTitle) + '&reason=' + encodeURIComponent( 'using [[User:Splarka/ajaxfilemove.js]];' +def );
 
  var url = mw.config.get('wgScriptPath') + '/api.php';
    if(typeof sajax_init_object === 'undefined') return;
  var req = sajax_init_object();
  req.open('POST', url, true);
  req.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
  req.setRequestHeader('Content-length', params.length);
  req.setRequestHeader('Connection', 'close');
  req.onreadystatechange = function() {
    if(req.readyState == 4 && req.status == 200) {
      eval("sfmMove(" + req.responseText + ",'" + req.responseText.replace(/\'/g,"`") + "')");
    }
  }
  req.send(params);
}
 
function sfmMove(obj,txt) {
  var out = document.getElementById('sfm-output');
  if(obj['error']) {
    out.appendChild(document.createTextNode('* Api error: ' + obj['error']['code'] + ' - ' + obj['error']['info'] + '\n* Please finish manually.'));
  } else if(obj['move'] && obj['move']['from'] && obj['move']['to']) {
    out.appendChild(document.createTextNode('* File [[' + obj['move']['from'] + ']] moved to [[' + obj['move']['to'] + ']]\n* Be sure to '));
    var a = document.createElement('a');
    a.setAttribute('href',mw.config.get('wgScript') + '?title=Special:WhatLinksHere&hidelinks=1&hidetrans=1&target=' + encodeURIComponent(obj['move']['to']));
    a.appendChild(document.createTextNode('Check for double redirects!'));
    out.appendChild(a);
  } else {
    out.appendChild(document.createTextNode('? Unexpected response: ' + txt + '\n* Please finish manually.'));
  }
}


//Mass rollback function
//Written by John254
//Adapted from User:Mr.Z-man/rollbackSummary.js
//Instructions: Selecting the "rollback all" tab when viewing a user's contributions history
//will open all rollback links displayed there. (Use with caution)
 
function rollbackEverythingButton() {
  var hasRollback = document.querySelectorAll("span.mw-rollback-link");
  if (hasRollback[0] && (document.title.indexOf("User contributions") != -1) ) {
    mw.util.addPortletLink('p-cactions', 'javascript:rollbackEverything()', "rollback all", "ca-rollbackeverything", "rollback all edits displayed here");
  }
}
$(rollbackEverythingButton);
function rollbackEverything() {
    for (var i in document.links) {
      if (document.links[i].href.indexOf('action=rollback') != -1) {
        window.open(document.links[i].href);
      }
    }
}

/*

 var ptLinksToAdd = [
        {
                label: "Snuggle",
                title: "Snuggle",
                url: "/wiki/Wikipedia:Snuggle",
                index: 5
        },

        {
                label: "New pages",
                title: "Feed of recently created pages",
                url: "/wiki/Special:NewPagesFeed",
                index: 5
        },
        {
                label: "AfD",
                url: "/wiki/Wikipedia:Articles_for_Deletion",
                index: 6
        },
        {
                label: "Edit score",
                url: "/wiki/Wikipedia:List_of_Wikipedians_by_number_of_edits",
                index: 7
        },
        {
                label: "Meta",
                url: "https://meta.wikimedia.org/wiki/User:Dan_Koehl",
                index: 8
        },
        {
                label: "Species",
                url: "https://species.wikimedia.org/wiki/User:Dan_Koehl",
                index: 9
        },
        {
                label: "sv:Voy",
                url: "https://sv.wikipedia.org/wiki/voy:Anv%C3%A4ndare:Dan_Koehl",
                index: 10
        },
        {
                label: "dawiki",
                url: "https://da.wikipedia.org/wiki/Bruger:Dan_Koehl",
                index: 11
        },
        {
                label: "Commons",
                url: "https://commons.wikimedia.org/wiki/User:Dan_Koehl",
                index: 12
        },
        {
               label: "Warn",

               url: "https://en.wikipedia.org/wiki/Category:User_warning_templates",
               index: 13

        },
        {
               label: "RVAN"
               url: "Wikipedia:Administrator_intervention_against_vandalism",
        }

 ];
 
 importScript('User:IagoQnsi/addptlinks.js');

*/

/* Adds a toolbox link to do a copyvio check on the given page. */

mw.loader.using("mediawiki.util", function() {
    mw.util.addPortletLink(
        "p-tb",
        "https://tools.wmflabs.org/copyvios/?lang=" + mw.config.get("wgContentLanguage") + "&project=" + mw.config.get("wgSiteName").toLowerCase() + "&title=" + encodeURIComponent(mw.config.get("wgPageName")),
        "Copyvio check",
        "t-copyvio-check",
        "Check this page for copyright violations"
    );
});

$(function () {
	var cn = "{{PAGENAMEBASE}}";
	if (mw.config.get('wgAction') === 'edit&redlink')
		mw.loader.using('moment', function () {
		setTimeout(function () {
			$('#wpUploadDescription').val(
			'{{Faktamall adelsätt\n'+
			'|släktnamn              ='+ cn +'\n'+
			'|bild                   =\n'+
			'|vapenbeskrivning       =\n'+
			'|bild2                  =\n'+
			'|bildbeskrivning2       =\n'+
			'|ursprung               =\n'+
			'|inflyttad              =\n'+
			'|känd                   =\n'+
			'|förgrenad              =\n'+
			'|upphöjd                =\n'+
            '|stamfar                =\n'+
			'|sätesgård              =\n'+
			'|adlad                  =\n'+
			'|andra_namn             =\n'+
			'|framstående            =\n'+
			'|valspråk               =\n'+
			'|utgrenad               =\n'+
			'|huvudman               =\n'+
			'<!-- introducerad adel på svenska Riddarhuset -->\n'+
			'|introducerad           =\n'+
			'|värdighet              =[[Adlig]]\n'+
			'|nr                     =\n'+
			'|riddarhusurl           =\n'+
			'|utslocknad             =\n'+
			'|sista_manliga_medlem   =\n'+
			'|sista_kvinnliga_medlem =\n'+
			'|url                    =\n'+
			'}}\n'+
			''+ cn +' är en svensk [[adelsätt]] med ursprung från Y, som adlades och introducerades på [[Sveriges Riddarhus]] som adlig ätt nummer . En gren av ätten upphöjdes till [[friherrlig]] rang.\n\n'+
			'== Adliga ätten X nummer ==\n'+
			'X adlades av och ätten introducerades samma år på Riddarhuset som adlig ätt med nummer Y.<ref name="Elgenstierna"/>\n\n'+
			'== Friherrliga ätten X nummer ==\n'+
			'{{Faktamall adelsätt\n'+
			'|släktnamn              =\n'+
			'|bild                   =\n'+
			'|vapenbeskrivning       =\n'+
			'|bild2                  =\n'+
			'|bildbeskrivning2       =\n'+
			'|ursprung               =\n'+
			'|inflyttad              =\n'+
			'|känd                   =\n'+
			'|förgrenad              =\n'+
			'|upphöjd                =\n'+
            '|stamfar                =\n'+
			'|sätesgård              =\n'+
			'|adlad                  =\n'+
			'|andra_namn             =\n'+
			'|framstående            =\n'+
			'|valspråk               =\n'+
			'|utgrenad               =\n'+
			'|huvudman               =\n'+
			'<!-- introducerad adel på svenska Riddarhuset -->\n'+
			'|introducerad           =\n'+
			'|värdighet              =[[Friherrlig]]\n'+
			'|nr                     =\n'+
			'|riddarhusurl           =\n'+
			'|utslocknad             =\n'+
			'|sista_manliga_medlem   =\n'+
			'|sista_kvinnliga_medlem =\n'+
			'|url                    =\n'+
			'}}\n'+
			'XX upphöjdes till [[friherre]] YYYY och hans ätt introducerades samma år som [[friherrlig]] ätt '+ cn +' med nummer YY på Riddarhuset. <ref name="Elgenstierna"/>\n\n'+
			'== Referenser ==\n'+
			'*{{Webbref |url= |titel= |hämtdatum='+ moment().format('YYYY-MM-DD') +' |författare= |efternamn=Elgenstierna |förnamn=Gustaf |författarlänk=Gustaf Elgenstierna |efternamn2= |förnamn2= |datum= |år= |månad= |format= |verk=[[Den introducerade svenska adelns ättartavlor]] |utgivare=[[Adelsvapen-Wiki]]  |sid= |språk= |doi= |arkivurl= |arkivdatum= |citat= |ref= }}\n'+
			'}}\n\n'+
			'=== Noter ===\n'+
			'<references>\n'+
			'<ref name="Elgenstierna">{{Webbref |url= |titel= |hämtdatum='+ moment().format('YYYY-MM-DD') +' |författare= |efternamn=Elgenstierna |förnamn=Gustaf |författarlänk=Gustaf Elgenstierna |efternamn2= |förnamn2= |datum= |år= |månad= |format= |verk=[[Den introducerade svenska adelns ättartavlor]] |utgivare=[[Adelsvapen-Wiki]]  |sid= |språk= |doi= |arkivurl= |arkivdatum= |citat= |ref= }}\n'+
			'}}</ref>\n'+
			'</references>\n\n'+
			'[[:Kategori:Svenska adelsätter]]\n'+
			'[[:Kategori:Svenska friherrliga ätter]]\n'
			);
		}, 100 );
	});
	//Om inte vapen finns, ladda upp vapen på commons
	else
		$('#n-uploadbtn>a').attr('href','//commons.wikimedia.org/w/index.php?title=Special:Upload&uselang='+
		((mw.config.get('wgUserLanguage') === 'en')?'': mw.config.get('wgUserLanguage')) + 'ownwork');
});