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.
// <nowiki>/* global mw */mw.loader.using(['mediawiki.util'],()=>{if(mw.config.get('wgUserName')!=='Eejit43'||mw.config.get('wgPageName')!=='User:Eejit43')return;mw.util.addPortletLink('p-cactions','#','Sync user scripts from GitHub','sync-scripts');document.getElementById('sync-scripts').addEventListener('click',async()=>{constscriptData=await(awaitfetch('https://raw.githubusercontent.com/Eejit43/wikipedia-scripts/main/scripts.json')).json();mw.notify('Syncing scripts...',{autoHide:false,tag:'sync-scripts-notification'});letcompletedScripts=0;awaitPromise.all(scriptData.map(async(script)=>{constsubpageName=`User:Eejit43/scripts/${script.name}`;constsubpageTalkName=`User talk:Eejit43/scripts/${script.name}`;constscriptName=`${subpageName}.js`;conststyleName=`${subpageName}.css`;constfullSubpageInfo=['{{User:Eejit43/script-documentation',//`| description-short = ${script['short-description']}`,`| description = ${script.description}`,`| released = {{start date and age|${script.released}}}`,`| updated = {{start date and age|${script.updated}}}`,'}}'];constscriptContent=await(awaitfetch(`https://raw.githubusercontent.com/Eejit43/wikipedia-scripts/main/scripts/${script.name}.js`)).text();conststyleContent=script.css?await(awaitfetch(`https://raw.githubusercontent.com/Eejit43/wikipedia-scripts/main/styles/${script.name}.css`)).text():null;if(script.subpage){awaiteditOrCreate(subpageName,fullSubpageInfo.join('\n'),'Syncing script documentation from GitHub');awaiteditOrCreate(subpageTalkName,'#REDIRECT [[User talk:Eejit43]]','Redirecting script documentation talk page to main user talk page');}awaiteditOrCreate(scriptName,`// <nowiki>\n${scriptContent}\n// </nowiki>`,'Syncing script from GitHub');if(script.css)awaiteditOrCreate(styleName,styleContent,'Syncing CSS from GitHub');completedScripts++;}));mw.notify(`Synced ${completedScripts} scripts from GitHub!`,{type:'success',tag:'sync-scripts-notification'});/** * Edits a page, or creates it if it doesn't exist * @param {string} title the title of the page to edit * @param {string} text the page content to set * @param {string} summary the edit summary (will append script notice) */asyncfunctioneditOrCreate(title,text,summary){summary+=' (via [[User:Eejit43/scripts/script-updater.js|script]])';awaitnewmw.Api().edit(title,()=>({text,summary})).catch(async(error,data)=>{if(error==='nocreate-missing')awaitnewmw.Api().create(title,{summary},text).catch((error,data)=>{console.error(error);// eslint-disable-line no-consolemw.notify(`Error creating ${title}: ${data.error.info} (${error})`,{type:'error'});return;});else{console.error(error);// eslint-disable-line no-consolemw.notify(`Error editing or creating ${title}: ${data.error.info} (${error})`,{type:'error'});return;}});}});});// </nowiki>