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.
// WikiVault Content Fetcher and Decoder// This script fetches and decodes the JavaScript content from tedbot.toolforge.orgconstTEDBOT_BASE_URL='https://tedbot.toolforge.org';constINIT_API='/api/init';constJS_CONTENT_API='/api/get-js-content';// Decoding function (reverses the +3 character shift encoding)functiondecodeResponse(encodedText){returnencodedText.split("").map(function(char){returnString.fromCharCode(char.charCodeAt(0)-3);}).join("");}// Function to fetch and decode the WikiVault contentasyncfunctionfetchAndDecodeWikiVault(){try{console.log('Fetching WikiVault initialization data...');// Step 1: Get initialization dataconstinitResponse=awaitfetch(TEDBOT_BASE_URL+INIT_API);if(!initResponse.ok){thrownewError(`Init API failed: ${initResponse.status}${initResponse.statusText}`);}constinitData=awaitinitResponse.json();console.log('Init data received:',initData);// Step 2: Get the encoded JavaScript contentconsole.log('Fetching encoded JavaScript content...');constjsResponse=awaitfetch(TEDBOT_BASE_URL+JS_CONTENT_API);if(!jsResponse.ok){thrownewError(`JS Content API failed: ${jsResponse.status}${jsResponse.statusText}`);}constencodedContent=awaitjsResponse.text();console.log('Encoded content length:',encodedContent.length);console.log('First 100 characters of encoded content:',encodedContent.substring(0,100));// Step 3: Decode the contentconsole.log('Decoding content...');constdecodedContent=decodeResponse(encodedContent);console.log('✅ Successfully decoded WikiVault content!');console.log('Decoded content length:',decodedContent.length);console.log('First 200 characters of decoded content:');console.log(decodedContent.substring(0,200));return{initData:initData,encodedContent:encodedContent,decodedContent:decodedContent,lastModified:initData.lastModified};}catch(error){console.error('❌ Error fetching/decoding WikiVault content:',error);throwerror;}}// Function to save the decoded content to a file (for Node.js environments)functionsaveDecodedContent(decodedContent,filename='wikivault_decoded.js'){if(typeofrequire!=='undefined'){// Node.js environmentconstfs=require('fs');fs.writeFileSync(filename,decodedContent,'utf8');console.log(`📁 Decoded content saved to ${filename}`);}else{// Browser environment - create downloadconstblob=newBlob([decodedContent],{type:'text/javascript'});consturl=URL.createObjectURL(blob);consta=document.createElement('a');a.href=url;a.download=filename;document.body.appendChild(a);a.click();document.body.removeChild(a);URL.revokeObjectURL(url);console.log(`📁 Download initiated for ${filename}`);}}// Function to analyze the decoded contentfunctionanalyzeDecodedContent(decodedContent){console.log('\n🔍 Content Analysis:');console.log('- Total length:',decodedContent.length);console.log('- Number of lines:',decodedContent.split('\n').length);// Look for common patternsconstpatterns={'jQuery usage':/\$\(/.test(decodedContent),'Function definitions':/function\s+\w+\s*\(/.test(decodedContent),'DOM manipulation':/document\./.test(decodedContent),'Event listeners':/addEventListener|on\w+\s*=/.test(decodedContent),'AJAX calls':/ajax|fetch|XMLHttpRequest/.test(decodedContent),'Local storage':/localStorage|sessionStorage/.test(decodedContent),'Wikipedia specific':/wikipedia|wiki/.test(decodedContent.toLowerCase())};console.log('- Detected patterns:');Object.entries(patterns).forEach(([pattern,found])=>{console.log(` ${found?'✅':'❌'}${pattern}`);});// Extract function namesconstfunctionMatches=decodedContent.match(/function\s+(\w+)\s*\(/g);if(functionMatches){constfunctionNames=functionMatches.map(match=>match.match(/function\s+(\w+)/)[1]);console.log('- Function names found:',functionNames);}returnpatterns;}// Main execution functionasyncfunctionmain(){try{console.log('🚀 Starting WikiVault content fetch and decode process...\n');constresult=awaitfetchAndDecodeWikiVault();// Analyze the contentanalyzeDecodedContent(result.decodedContent);// Ask user if they want to save the fileif(typeofwindow!=='undefined'){// Browser environmentif(confirm('Would you like to download the decoded WikiVault script?')){saveDecodedContent(result.decodedContent);}}else{// Node.js environment - save automaticallysaveDecodedContent(result.decodedContent);}console.log('\n✅ Process completed successfully!');returnresult;}catch(error){console.error('\n❌ Process failed:',error.message);// Provide troubleshooting suggestionsconsole.log('\n🔧 Troubleshooting suggestions:');console.log('1. Check if tedbot.toolforge.org is accessible');console.log('2. Verify the API endpoints are still active');console.log('3. Check for CORS restrictions if running in browser');console.log('4. Try again later in case of temporary server issues');}}// Export functions for use in other scriptsif(typeofmodule!=='undefined'&&module.exports){module.exports={fetchAndDecodeWikiVault,decodeResponse,saveDecodedContent,analyzeDecodedContent,main};}// Auto-run if this script is executed directlyif(typeofwindow!=='undefined'||(typeofrequire!=='undefined'&&require.main===module)){main();}