User:Scaledish/Scripts/404.js
Appearance
From Wikipedia, the free encyclopedia
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump.
This code will be executed when previewing this page.
This code will be executed when previewing this page.
This user script seems to have a documentation page at User:Scaledish/Scripts/404.
mw.loader.using(['mediawiki.util'],function(){ // Add button to the "More" tab mw.util.addPortletLink( 'p-cactions',// Portlet ID for "More" tab '#',// Href (dummy) 'Check for 404s',// Link text 'ca-check-404',// Link ID 'Check all citations for 404s'// Tooltip ); // Click handler for the button $('#ca-check-404').on('click',function(e){ e.preventDefault(); $('.mw-parser-output a.external').each(function(_,link){ consthref=link.href; // Skip web.archive.org links if(href.includes('web.archive.org'))return; if(href.includes('archive.is'))return; // Special handling for facebook.com if(href.includes('facebook.com')){ $(link).css({ 'outline':'1px dashed gray', }).attr('title','Facebook must be checked manually.'); return; } // Special handling for x.com if(href.includes('x.com')){ $(link).css({ 'outline':'1px dashed gray', }).attr('title','Twitter must be checked manually.'); return; } constcitationURL='/api/rest_v1/data/citation/mediawiki/'+encodeURIComponent(href); $.ajax({ url:citationURL, method:'GET', success:function(){ // Valid citation, do nothing }, error:function(xhr){ if(xhr.status===404){ $(link).css({ 'outline':'1px dashed red', }).attr('title','Unresolvable citation: not recognized by MediaWiki citation API'); } } }); }); }); });