Jump to content

User:Suntooooth/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.
// Enable caching for resource loads, see [[User:SD0001/Making_user_scripts_load_faster]], @revision 7
if(!/\bnocache=\b/.test(location.href)){let e=mw.config.values,t="text/javascript",r="text/css",n=(n,o,i)=>(n=n.replace(/special:mypage/i,"User:"+e.wgUserName),$.get("https://"+o+"/w/api.php?titles="+n+"&origin=*&format=json&formatversion=2&uselang=content&maxage=86400&smaxage=86400&action=query&prop=revisions|info&rvprop=content&rvlimit=1&inprop=protection").then(e=>{let a=e.query.pages[0];if(!a.missing){if(2!==a.ns&&8!==a.ns&&!a.protection.find(e=>"edit"===e.type&&"sysop"===e.level))return $.Deferred().reject('Refused to load "'+n+'"@'+o+": unprotected page");let l=a.revisions[0].content;if(i&&i!==t||"javascript"!==a.contentmodel){if(i!==r||"css"!==a.contentmodel)return $.Deferred().reject('Refused to load "'+n+'"@'+o+": content type mismatch");mw.loader.addStyleTag(l)}else document.head.appendChild(document.createElement("script")).innerHTML=l}})),o=e.wgServerName,i=e=>{let t=/^(?:(?:https:)?\/\/(.*))?\/w\/index.php/.exec(e),r=/\btitle=([^=?&]*)/.exec(e);return t&&r&&/\baction=raw\b/.test(e)&&/\bctype=/.test(e)?[r[1],t[1]||o]:null};window.importScript=e=>{n(encodeURIComponent(e),o,t)},window.importStyleSheet=e=>{n(encodeURIComponent(e),o,r)};let a=mw.loader.load;mw.loader.load=function(e,t){let r=i(e);r?n(r[0],r[1],t):a.apply(mw.loader,[...arguments])};let l=mw.loader.getScript;mw.loader.getScript=function(e){let r=i(e);return r?n(r[0],r[1],t):l.apply(mw.loader,[...arguments])}}

// Lock myself out between 2am and 6am, because sleep-deprived editing is causing problems. Forked from [[User:Anomie/lockout.js]]
(function(){
	if (mw.config.get('wgAction') !== 'edit') {
        return;
    }
    
    if(!document.body){
        // Page not loaded yet!
        setTimeout(arguments.callee, 100);
        return;
    }

    var s= 2  *3600+  0  *60; // Start lockout time
    var e= 6  *3600+  0  *60; // End lockout time
    
    var dt=new Date();
    var t=dt.getHours()*3600+dt.getMinutes()*60+dt.getSeconds();

    if(t<s){
        // Not time yet, clear lockout and try again later
        setTimeout(arguments.callee, Math.min(600000,s-t)*1000);
        document.body.style.display='';
        return;
    }
    if(t>=e){
        // Time passed, clear lockout and wait until later
        setTimeout(arguments.callee, Math.min(600000,86400-t)*1000);
        document.body.style.display='';
        return;
    }
    
    // Lock out! And repeat the check every second so I can't just firebug my way past it.
    document.body.style.display='none';
    setTimeout(arguments.callee, 1000);
})();



// -------- 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]]

// link to search twl
mw.loader.load( '//meta.wikimedia.org/wiki/User:Diegodlh/search-wpl.js?action=raw&ctype=text/javascript' );


// -------- 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]]

// unpipe links
importScript('User:Nardog/Unpipe.js'); // Backlink: [[User:Nardog/Unpipe.js]]

// link to a range of contributions
importScript('User:Andrybak/Scripts/Contribs_ranger.js'); // Backlink: [[User:Andrybak/Scripts/Contribs_ranger.js]]

// double click on diff to undo like AWB
importScript('User:Nardog/DiffUndo.js'); // Backlink: [[User:Nardog/DiffUndo.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]]

// helps with closing peer reviews
importScript('User:Writ Keeper/Scripts/peerReviewCloser.js');

// afd sorting
importScript('User:Enterprisey/delsort.js'); // Backlink: [[User:Enterprisey/delsort.js]]

// opens articles to rate in a new tab + opens rater automatically
importScript('User:SD0001/UnassessedArticleLinks.js'); // Backlink: [[User:SD0001/UnassessedArticleLinks.js]]

// DYK prep building (one day...)
importScript('User:Theleekycauldron/DYK_promoter.js'); // Backlink: [[User:Theleekycauldron/DYK_promoter.js]]

// merge helper
importScript('User:SD0001/easy-merge.js'); // Backlink: [[User:SD0001/easy-merge.js]]

// removes categories from drafts
importScript('User:DannyS712/Draft_no_cat.js'); // Backlink: [[User:DannyS712/Draft_no_cat.js]]

// gan review tool
importScript('User:Novem_Linguae/Scripts/GANReviewTool.js'); // Backlink: [[User:Novem_Linguae/Scripts/GANReviewTool.js]]

// npp helper
importScript('User:Schminnte/PageCuration.js'); // Backlink: [[User:Schminnte/PageCuration.js]]

// adds "not around" template to talk pages
importScript('User:Andrybak/Scripts/Not_around.js'); // Backlink: [[User:Andrybak/Scripts/Not_around.js]]

// Category:Articles missing coordinates with coordinates on Wikidata
importScript('User:Jeeputer/coordInserter.js'); // Backlink: [[User:Jeeputer/coordInserter.js]]

// good article review nominator
importScript('User:SD0001/GAR-helper.js'); // Backlink: [[User:SD0001/GAR-helper.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]]

// featured article nomination viewer
importScript('User:Gary/nominations viewer.js'); // Backlink: [[Wikipedia:Nominations Viewer]]

// move protection topicon
importScript('User:Aaron_Liu/MoveTop.js'); // Backlink: [[User:Aaron_Liu/MoveTop.js]]

// more menu option to only see revisions by blocked users
importScript('User:Novem Linguae/Scripts/BlockedUserHistory.js'); // Backlink: [[User:Novem Linguae/Scripts/BlockedUserHistory.js]]

// see move history of pages
importScript('User:Nardog/MoveHistory.js'); // Backlink: [[User:Nardog/MoveHistory.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]]