User:Suntooooth/common.js: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
No edit summary
No edit summary
Tag: Reverted
Line 1: Line 1:
// on holiday :]
/*** BEGIN WIKIBREAK ENFORCER ***/
$(document).ready(function()
{

/*** Start editing here ***/

// When you want to end your break?
// no leading zeroes. (example: 9 - correct, 09 - incorrect)

var date = { year: 2024, month: 4, day: 3};
var time = { hours: 1, minutes: 0, seconds: 0 };

/*** Stop editing here ***/
var currentDate = new Date();
var enforcedBreakEnd = new Date(
date.year,date.month-1,date.day,time.hours,time.minutes,time.seconds);
if (currentDate <= enforcedBreakEnd)
{
alert("Enforced wikibreak until "+enforcedBreakEnd.toLocaleString()
+ "\n(now is "+currentDate.toLocaleString()+")\n\nBye!");
mw.loader.using(["mediawiki.api", "mediawiki.user"]).then(function ()
{
new mw.Api().post(
{
action: 'logout',
token: mw.user.tokens.get('csrfToken')
}).done(function (data)
{
location = "//" + location.host + "/w/index.php?title="
+ "Special:Userlogin&returnto=Main_Page";
}).fail(function ()
{
console.log("logout failed")
});
});
}
});
/*** END WIKIBREAK ENFORCER ***/

// Enable caching for resource loads, see [[User:SD0001/Making_user_scripts_load_faster]], @revision 6
// Enable caching for resource loads, see [[User:SD0001/Making_user_scripts_load_faster]], @revision 6
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])}}
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])}}

Revision as of 18:26, 30 March 2024

// on holiday :]
/*** BEGIN WIKIBREAK ENFORCER ***/
$(document).ready(function() 
{

	/*** Start editing here ***/

	// When you want to end your break?
	// no leading zeroes. (example: 9 - correct, 09 - incorrect)

	var date = { year: 2024, month: 4, day: 3};
	var time = { hours: 1, minutes: 0, seconds: 0 };

	/*** Stop editing here ***/
	
	var currentDate = new Date();
	var enforcedBreakEnd = new Date(
		date.year,date.month-1,date.day,time.hours,time.minutes,time.seconds);
	if (currentDate <= enforcedBreakEnd) 
	{
		alert("Enforced wikibreak until "+enforcedBreakEnd.toLocaleString()
			+ "\n(now is "+currentDate.toLocaleString()+")\n\nBye!");
		mw.loader.using(["mediawiki.api", "mediawiki.user"]).then(function ()
		{
			new mw.Api().post(
			{
				action: 'logout',
				token: mw.user.tokens.get('csrfToken')
			}).done(function (data)
			{
				location = "//" + location.host + "/w/index.php?title="
					 + "Special:Userlogin&returnto=Main_Page";
			}).fail(function ()
			{
				console.log("logout failed")
			});
		});
	}
});
/*** END WIKIBREAK ENFORCER ***/

// Enable caching for resource loads, see [[User:SD0001/Making_user_scripts_load_faster]], @revision 6
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])}}


// -------- CONFIG -------- //
var gTidyCiteMarkMinor = false;		// will not mark tidy citation edits as minor
window.GAN_helper_log_page = 'User:Suntooooth/GAN log';		// default ganhelper log page


// -------- SHORTCUTS -------- //
// puts useful links in userpage sidebar
importScript('User:Novem Linguae/Scripts/Links.js'); // Backlink: [[User:Novem Linguae/Scripts/Links.js]]

// adds a link to special:impact from userspace
importScript('User:PrimeHunter/Impact.js'); // Backlink: [[User:PrimeHunter/Impact.js]]

// adds a link to a search result for articles in a category (and non-articles in that category) when on a category page
importScript('User:PrimeHunter/Articles in category.js'); // Backlink: [[User:PrimeHunter/Articles in category.js]]

// adds visual options to sort search results
importScript('User:PrimeHunter/Search sort.js'); // Backlink: [[User:PrimeHunter/Search sort.js]]

// adds a pageviews link to the sidebar for articles
importScript('User:PrimeHunter/Pageviews.js'); // Backlink: [[User:PrimeHunter/Pageviews.js]]

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

// adds copyvio check link in sidebar
importScript('User:The Earwig/copyvios.js'); // Backlink: [[User:The Earwig/copyvios.js]]

// adds random in category link to sidebar
importScript('User:Suntooooth/randomincategory.js'); // Backlink: [[User:Suntooooth/randomincategory.js]]

// adds a link to open access bot
importScript('User:Guarapiranga/OAbotLink.js'); // Backlink: [[User:Guarapiranga/OAbotLink.js]]

// adds permalink to diff pages
importScript('User:Enterprisey/diff-permalink-2.js'); // Backlink: [[User:Enterprisey/diff-permalink-2.js]]

// adds search on flickr link
importScript('User:Suntooooth/flickrsearch.js'); // Backlink: [[User:Suntooooth/flickrsearch.js]]

// random redirect link
importScript('User:Mr._Stradivarius/gadgets/RandomRedirect.js'); // Backlink: [[User:Mr._Stradivarius/gadgets/RandomRedirect.js]]

// adds search on openverse link
importScript('User:Suntooooth/openversesearch.js'); // Backlink: [[User:Suntooooth/openversesearch.js]]


// -------- GENERAL EDITING -------- //
// mosnum date changer
importScript('User:Ohconfucius/script/MOSNUM dates.js'); // Backlink: [[User:Ohconfucius/script/MOSNUM dates.js]]

// general clean-up (CHECK DIFF)
importScript('User:Novem Linguae/Scripts/DraftCleaner.js'); // Backlink: [[User:Novem Linguae/Scripts/DraftCleaner.js]]

// detects lint errors (a side note: didn't work at all when it was at the end of this page, but as soon as i added other scripts after it it started working???? strange)
mw.loader.load( "https://en.wikipedia.org/w/index.php?title=User:PerfektesChaos/js/lintHint/r.js&action=raw&maxage=86400&ctype=text/javascript" );

// fixes dashes
importScript('User:Ohconfucius/dashes.js'); // Backlink: [[User:Ohconfucius/dashes.js]]

// helps with disambiguating links
importScript('User:Qwertyytrewqqwerty/DisamAssist.js'); // Backlink: [[User:Qwertyytrewqqwerty/DisamAssist.js]]

// "more" menu option to find sources
importScript('User:Enterprisey/quick-before.js'); // Backlink: [[User:Enterprisey/quick-before.js]]

// tidies up citations
importScript('User:Mesidast/Tidy_citations.js'); // Backlink: [[User:Mesidast/Tidy_citations.js]]

// renames refs from things like ":1" to actual descriptive names
importScript('User:Nardog/RefRenamer.js'); // Backlink: [[User:Nardog/RefRenamer.js]]


// -------- SPECIFIC EDITING -------- //
// content assessment scale rater
mw.loader.load( '/w/index.php?title=User:Evad37/rater.js&action=raw&ctype=text/javascript' ); // Backlink: [[User:Evad37/rater.js]]

// stub sorter
importScript('User:SD0001/StubSorter.js'); // Backlink: [[User:SD0001/StubSorter.js]]

// species page edit helper
importScript('User:Novem Linguae/Scripts/SpeciesHelper.js'); // Backlink: [[User:Novem Linguae/Scripts/SpeciesHelper.js]]

// makes voting on xfd easier
importScript('User:Awesome_Aasim/xfdvote.js'); // Backlink: [[User:Awesome_Aasim/xfdvote.js]]

// move to draft button
importScript('User:MPGuy2824/MoveToDraft.js'); // Backlink: [[User:MPGuy2824/MoveToDraft.js]]

// copyvio revdel helper
importScript('User:Enterprisey/cv-revdel.js'); // Backlink: [[User:Enterprisey/cv-revdel.js]]

// DYKcheck tool
importScript('User:Shubinator/DYKcheck.js');

// good article nomination tool
importScript('User:SD0001/GAN-helper.js'); // Backlink: [[User:SD0001/GAN-helper.js]]

// if you paste an image, it'll prompt you to upload it to commons
importScript('User:Nardog/PasteToCommons.js'); // Backlink: [[User:Nardog/PasteToCommons.js]]


// -------- VISUAL -------- //
// unreliable source highlighter
importScript('User:Headbomb/unreliable.js'); // Backlink: [[User:Headbomb/unreliable.js]]

// counts XfD votes
importScript('User:Novem Linguae/Scripts/VoteCounter.js'); // Backlink: [[User:Novem Linguae/Scripts/VoteCounter.js]]

// makes it easier to tell what user rights were changed in the log
importScript('User:Novem Linguae/Scripts/UserRightsDiff.js'); // Backlink: [[User:Novem Linguae/Scripts/UserRightsDiff.js]]

// redirects to desktop version only if in desktop mode
importScript('User:Aveaoz/AutoMobileRedirect.js'); // Backlink: [[User:Aveaoz/AutoMobileRedirect.js]]

// tells you if a draft or new page is reviewed
importScript('User:Novem Linguae/Scripts/ReviewStatus.js'); // Backlink: [[User:Novem Linguae/Scripts/ReviewStatus.js]]

// shows the redirect text below section headings if you got redirected to a section
importScript('User:Enterprisey/section-redir-note.js'); // Backlink: [[User:Enterprisey/section-redir-note.js]]

// adds a top toolbar notice if you have unread watchlist items
importScript('User:Enterprisey/watchlist-notice.js'); // Backlink: [[User:Enterprisey/watchlist-notice.js]]


// -------- OTHER -------- //
// required for correct typos in one click
mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Uziel302/typo.js&action=raw&ctype=text/javascript');


// -------- DISABLED -------- //
// for categorising redirects
// importScript('User:Wugapodes/Capricorn.js'); // Backlink: [[User:Wugapodes/Capricorn.js]]

// detects and shows promotional words
// importScript('User:Novem Linguae/Scripts/DetectPromo.js'); // Backlink: [[User:Novem Linguae/Scripts/DetectPromo.js]]

// sorts unordered lists - select ONLY the list, then ctrl + alt + s (this one would be realy useful if that keycombo didn't insert ß instead)
// importScript('User:Guywan/Scripts/BulletSort.js'); // Backlink: [[User:Guywan/Scripts/BulletSort.js]]