Jump to content

User:Ahecht/common.js

From Wikipedia, the free encyclopedia
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.
// __NOINDEX__

/*****************************
*         Variables          *
*****************************/
//var refreshReuseBubble = true;
//pagemoveDoPostMoveCleanup = true;
window.catALotPrefs = {"watchlist":"preferences","minor":true,"editpages":true,"docleanup":false,"subcatcount":10,"redir_category": "Wikipedia soft redirected categories"};
window.ADMINHIGHLIGHT_INTERVAL = 3600000*12; //12 hours

/*****************************
*   All-namespace scripts    *
*****************************/
mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Ahecht/sandbox/Scripts/pageswap.js&action=raw&ctype=text/javascript' ); // Page Swap [[User:Ahecht/Scripts/pageswap]]
//mw.loader.load( '//meta.wikimedia.org/w/index.php?title=User:Zhaofeng_Li/Reflinks.js&action=raw&ctype=text/javascript' );// Refill [[User:Zhaofeng Li/Reflinks.js]]
mw.util.addPortletLink( "p-tb", 'https://refill.toolforge.org/ng/result.php?wiki=en&page=' + encodeURIComponent( mw.config.get( "wgPageName" ) ), "reFill", "t-refill2" );
mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Ahecht/sandbox/Scripts/massmove.js&action=raw&ctype=text/javascript' ); // Mass Move [[User:Ahecht/Scripts/massmove.js]] [[User:Plastikspork/massmove.js]]
mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Ahecht/Scripts/FileExporter.js&action=raw&ctype=text/javascript' ); // FileExporter [[:en:User:Ahecht/Scripts/FileExporter.js]]
//mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:DannyS712/Easy-link.js&action=raw&ctype=text/javascript'); // Easy Link [[User:DannyS712/Easy-link.js]]
mw.loader.load( '/w/index.php?title=User:Enterprisey/copy-section-link.js&action=raw&ctype=text/javascript' ); // Backlink: [[User:Enterprisey/copy-section-link.js]]
mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Jackmcbarn/applyPST.js&action=raw&ctype=text/javascript'); // Apply Pre-save Transform [[User:Jackmcbarn/applyPST.js]]
mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Ahecht/sandbox/Scripts/JWB.js/load.js&action=raw&ctype=text/javascript'); // Java Wiki Browser [[User:Joeytje50/JWB]]
mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:PerfektesChaos/js/lintHint/r.js&action=raw&bcache=1&maxage=86400&ctype=text/javascript' );// LintHint [[User:PerfektesChaos/js/lintHint]]
//mw.loader.load( '//meta.wikimedia.org/w/index.php?title=User:Indic-TechCom/Script/massMover.js&action=raw&ctype=text/javascript' ); // Mass Mover
//mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Anomie/ajaxpreview.js&action=raw&ctype=text/javascript' ); //[[User:Anomie/ajaxpreview.js]]
//mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:PhantomTech/scripts/AFCRHS.js&action=raw&ctype=text/javascript' ); // AFC Redirect Helper Script [[User:PhantomTech/scripts/AFCRHS.js]
//mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Salix alba/Citoid.js&action=raw&ctype=text/javascript' ); // Citoid [[User:Salix alba/Citoid.js]]
mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:PrimeHunter/Source links.js&action=raw&ctype=text/javascript' ); // Source links [[User:PrimeHunter/Source links.js]]
mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Enterprisey/diff-permalink.js&action=raw&ctype=text/javascript' ); // Backlink: [[User:Enterprisey/diff-permalink.js]]
mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Ahecht/sandbox/Scripts/sandbox.js&action=raw&ctype=text/javascript' ); // Sandbox [[User:Ahecht/Scripts/sandbox.js]]
mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Ahecht/previewtemplatelastmod.js&action=raw&ctype=text/javascript' ); // Linkback: [[User:Anomie/previewtemplatelastmod.js]]

// Warn when restoring old ID
qs = new URLSearchParams(window.location.search);
if ( qs.get('action') == 'edit' && qs.get('oldid') !== null && (qs.get('oldid') != mw.config.get('wgCurRevisionId')) ) {
	$( '#wpSaveWidget input:first' ).attr('value', (i,v) => v + ' (from ' + qs.get('oldid') + ')');
}

/*****************************
* Namespace-specific scripts *
*****************************/

if ([-1, 0, 6].includes(mw.config.get('wgNamespaceNumber'))) {mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Ahecht/sandbox/Scripts/potd-helper.js&action=raw&ctype=text/javascript' );} //[[User:Ahecht/Scripts/potd-helper.js]]

if (mw.config.get('wgNamespaceNumber')%2 || mw.config.get('wgNamespaceNumber') == 4) { //talk and Wikipedia namespaces
	mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:TheTVExpert/rmCloser.js&action=raw&ctype=text/javascript' ); // Backlink: [[User:TheTVExpert/rmCloser.js]]
	mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Chlod/Scripts/UserHighlighter.js&action=raw&ctype=text/javascript' ); // Backlink: [[User:Chlod/Scripts/UserHighlighter.js]]
}

switch (mw.config.get('wgNamespaceNumber')) {
case 0: // Mainspace
	mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:MPGuy2824/MoveToDraft.js&action=raw&ctype=text/javascript' ); // Move to Draft [[User:MPGuy2824/MoveToDraft.js]]
	mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Kaniivel/RefConsolidate_start.js&action=raw&ctype=text/javascript' ); // [[User:Kaniivel/Reference Organizer]]
	$.when( mw.loader.using('mediawiki.util'), $.ready ).then( function() { //R from middle name
		mw.util.addPortletLink( 'p-cactions', '', 'R from middle name', 'un-cactions', 'Create redirect from page with first, middle, and last name',null,null);
		document.getElementById("un-cactions").getElementsByTagName("a")[0].setAttribute('onclick', 'unnecessary();return false;');
	} );
	//mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Headbomb/unreliable.js&action=raw&ctype=text/javascript' ); // Backlink: [[User:Headbomb/unreliable.js]]
	mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Nardog/RefRenamer.js&action=raw&ctype=text/javascript');// [[User:Nardog/RefRenamer.js]]
	break;
case 1: //Article Talk:
	mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Evad37/rater.js&action=raw&ctype=text/javascript' ); // [[User:Evad37/rater]]
	mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:DannyS712/PageMoverClosure.js&action=raw&ctype=text/javascript' ); // [[User:DannyS712/PageMoverClosure.js]]
	break;
case 2:
case 3: //User: and User talk:
	mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Mr. Stradivarius/gadgets/Draftify.js&action=raw&ctype=text/javascript' ); // Draftify [[User:Mr. Stradivarius/gadgets/Draftify.js]]
	if(mw.config.get('wgPageName').split("/")[0] == "User_talk:Ahecht") {mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Evad37/OneClickArchiver.js&action=raw&ctype=text/javascript' );} // Backlink: [[User:Evad37/Scripts/OneClickArchiver]]
	break;
case 4: // Wikipedia:
	mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:APerson/delsort.js&action=raw&ctype=text/javascript' ); // AfD Sorter [[User:APerson/delsort.js]] 
	//mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Enterprisey/easy-brfa.js&action=raw&ctype=text/javascript' ); // EasyBRFA [[User:Enterprisey/easy-brfa.js]] 
	mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:DannyS712/PageMoverClosure.js&action=raw&ctype=text/javascript' ); // [[User:DannyS712/PageMoverClosure.js]]
	mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Eejit43/scripts/rmtr-helper.js&action=raw&ctype=text/javascript' ); // [[User:Eejit43/scripts/rmtr-helper.js]]
	mw.loader.load( '/w/index.php?title=User:MusikAnimal/userRightsManager.js&action=raw&ctype=text/javascript' ); // Backlink: [[User:MusikAnimal/userRightsManager.js]]
	break;
case 10: // Template:
	mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Ahecht/Scripts/infoboxgap.js&action=raw&ctype=text/javascript' ); // Infobox gap [[User:Ahecht/Scripts/infoboxgap.js]]
	break;
case 11:
case 829: //Template talk: or Module talk:
	mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Ahecht/Scripts/ETp.js&action=raw&ctype=text/javascript' ); // Answer Template edit request [[User:Ahecht/Scripts/ETp.js]]
	mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Jackmcbarn/editProtectedHelper.js&action=raw&ctype=text/javascript' ); // Edit Protected Helper [[User:Jackmcbarn/editProtectedHelper.js]]
	mw.loader.load( '/w/index.php?title=User:Evad37/OneClickArchiver.js&action=raw&ctype=text/javascript' ); // Backlink: [[User:Evad37/OneClickArchiver.js]]
	break;
case 14: // Category:
	mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:קיפודנחש/cat-a-lot.js&action=raw&ctype=text/javascript' ); // Cat-a-lot [[User:קיפודנחש/cat-a-lot.js]]
	$.when( mw.loader.using('mediawiki.util'), $.ready ).then( function() { //Hide userspace items
		mw.util.addPortletLink( 'p-cactions', '', 'Hide userspace items', 'hu-cactions', 'Hide User: and User talk: items from category',null,null);
		document.getElementById("hu-cactions").getElementsByTagName("a")[0].setAttribute('onclick', 'hideUser();return false;');
	} );
	break;
case 118:
case 119: // Draft: and Draft talk:,
	mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Ahecht/sandbox/Scripts/draft-sorter.js&action=raw&ctype=text/javascript' ); //Draft Sorter [[User:Ahecht/Scripts/draft-sorter.js]]
	break;
case -1: //Special
	mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:קיפודנחש/cat-a-lot.js&action=raw&ctype=text/javascript' ); // Cat-a-lot [[User:קיפודנחש/cat-a-lot.js]]
	mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Ahecht/Scripts/cookies.js&action=raw&ctype=text/javascript' ); // Show Wikipedia Cookies [[User:Ahecht/Scripts/cookies.js]]
	mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Ahecht/sandbox/Scripts/watchlistcleaner.js&action=raw&ctype=text/javascript' ); // Watchlist cleaner [[User:Ahecht/Scripts/watchlistcleaner.js]]
	// mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Andy_M._Wang/massretarget.js&action=raw&ctype=text/javascript' ); // Backlink: [[User:Andy M. Wang/massretarget]]
	// Automatically tick the "Move subpages" option when moving pages.
	var moveSubpagesBox = document.getElementsByName("wpMovesubpages")[0];
	if (moveSubpagesBox !== null && moveSubpagesBox !== undefined) {
		moveSubpagesBox.checked = true;
	}
	//Link to user's contributions next to User Talk pages in Special:Contributions
	$('ul.mw-contributions-list li:has(a[title^="User talk:"])').each(function() {
		$(this).append($('<a></a>').attr('href',mw.config.get('wgArticlePath').replace('$1','Special:Contributions/'+$(this).find('a[title^="User talk:"]').attr('title').replace('User talk:', 'User:'))).text('(contributions)'));
	});

}

/*****************************
*      Global scripts        *
*****************************/
//The following scripts have been moved to https://meta.wikimedia.org/wiki/User:Ahecht/global.js
//mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Ahecht/Scripts/UTCLiveClock.js&action=raw&ctype=text/javascript' ); // Recursive UTC Live Clock [[User:Ahecht/Scripts/UTCLiveClock.js]]
//mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:SiBr4/TemplateSearch.js&action=raw&ctype=text/javascript' ); // Template Search [[User:SiBr4/TemplateSearch.js]]
//mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Anomie/useridentifier.js&action=raw&ctype=text/javascript' ); // User Identifier [[User:Anomie/useridentifier.js]]
//mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Ahecht/Scripts/CVD.js&action=raw&ctype=text/javascript' ); // Copyvio Detector [[User:Ahecht/Scripts/CVD.js]]
//mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:Ahecht/Scripts/refresh.js&action=raw&ctype=text/javascript' ); // Refresh [[User:Ahecht/Scripts/refresh.js]]