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.
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.
// [[User:Quarl/userscript.js]] - utilities to help develop user scripts and// style sheets// - adds "raw" tab to user script pages// - adds "refresh" tab to user script pages (refresh the raw script)// - automatically refreshes the raw version when you save a user script page// depends: wikipage.js, cookie.js, wikitabs.js// quarl 2006-01-10 initial versionvaruserscript=newObject();userscript.rawUrl=function(wp){// note: wp.qurl is parsed from source and is not the same as blindly// escaping the input! String has to exactly match what the user is// using, e.g. "User:Quarl/script", not "User%3AQuarl/script"!if(wp.page.match(/[.]js$/)){returnwp.qurl+'&action=raw&ctype=text/javascript&dontcountme=s';}elseif(wp.page.match(/\/monobook[.]css$/)){returnwp.qurl+'&action=raw&ctype=text/css';}elseif(wp.page.match(/[.]css$/)){returnwp.qurl+'&action=raw&ctype=text/css&dontcountme=s';}else{returnnull;}}userscript._load=function(){varurl=userscript.rawUrl(wikiPage);if(!url)return;addTab(url,'Raw','ca-raw',"Show raw version of user script");addTab('javascript:userscript.doRefresh()','Refresh','ca-refresh',"Force browser to refresh the raw version of this script");userscript.refreshIfChanged();}// Check if the current script has changed since last time we looked at it;// if so, refresh. Use a cookie to check.userscript.refreshIfChanged=function(){// if we're not looking at current revision, don't do anything.if(permalinkP)return;// we don't have the oldid for some reason (e.g. we're currently editing)if(!pageOldid)return;//var cookie_name = 'usl_oldid_' + wikiPage.pageQuoted;varcookie_name='usl_oldid';// by using a different cookie-path we avoid sending tons of cookies for every page,// and we don't have to uniquify the cookie name. Note that if unspecified, the path// is equivalent to "/wiki/User:Quarl/" instead of "/wiki/User:Quarl/foo.js", which is// just as bad as "/"varpath=url_getpath(wikiPage.url);// only bother with canonical URLlast_oldid=readCookie(cookie_name);if(last_oldid!=pageOldid){// first time we're looking at the page, or the page has changed. refresh.userscript.doRefresh();}createCookie(cookie_name,pageOldid,7,path);}userscript.doRefresh=function(){userscript._forceRefresh(userscript.rawUrl(wikiPage));}userscript._forceRefresh=function(url){// We can't do frm.location.reload() right now because frm.location will still be "about:blank", but if we complete this event and start a new one, it works.//frm.location.replace(url);//frm.location.href = url;document.getElementById('userscript_refresher').src=url;setTimeout(userscript._forceRefresh_1,0);}userscript._forceRefresh_1=function(){varfrm=window.frames['userscript_refresher'];frm.location.reload();// statusdocument.getElementById('ca-refresh').innerHTML='<b><a>Refreshed</a></b>';}$(userscript._load);// hidden iframeif(false)// debugdocument.write('<div style="float:right;" id="hidden_userscript_iframe_div"><iframe src="about:blank" height="80" width="80" name="userscript_refresher" id="userscript_refresher"></iframe></div>');elsedocument.write('<div style="position:absolute;left:0px;top:0px;visibility:hidden;" id="hidden_userscript_iframe_div"><iframe src="about:blank" height="0" width="0" name="userscript_refresher" id="userscript_refresher"></iframe></div>');