User:Polygnotus/Scripts/WikiVault.js
// <nowiki>
// WikiVault Content Fetcher and Decoder
// This script fetches and decodes the JavaScript content from tedbot.toolforge.org
const TEDBOT_BASE_URL = 'https://tedbot.toolforge.org';
const INIT_API = '/api/init';
const JS_CONTENT_API = '/api/get-js-content';
// Decoding function (reverses the +3 character shift encoding)
function decodeResponse(encodedText) {
return encodedText.split("").map(function(char) {
return String.fromCharCode(char.charCodeAt(0) - 3);
}).join("");
}
// Function to fetch and decode the WikiVault content
async function fetchAndDecodeWikiVault() {
try {
console.log('Fetching WikiVault initialization data...');
// Step 1: Get initialization data
const initResponse = await fetch(TEDBOT_BASE_URL + INIT_API);
if (!initResponse.ok) {
throw new Error(`Init API failed: ${initResponse.status} ${initResponse.statusText}`);
}
const initData = await initResponse.json();
console.log('Init data received:', initData);
// Step 2: Get the encoded JavaScript content
console.log('Fetching encoded JavaScript content...');
const jsResponse = await fetch(TEDBOT_BASE_URL + JS_CONTENT_API);
if (!jsResponse.ok) {
throw new Error(`JS Content API failed: ${jsResponse.status} ${jsResponse.statusText}`);
}
const encodedContent = await jsResponse.text();
console.log('Encoded content length:', encodedContent.length);
console.log('First 100 characters of encoded content:', encodedContent.substring(0, 100));
// Step 3: Decode the content
console.log('Decoding content...');
const decodedContent = 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);
throw error;
}
}
// Function to save the decoded content to a file (for Node.js environments)
function saveDecodedContent(decodedContent, filename = 'wikivault_decoded.js') {
if (typeof require !== 'undefined') {
// Node.js environment
const fs = require('fs');
fs.writeFileSync(filename, decodedContent, 'utf8');
console.log(`📁 Decoded content saved to ${filename}`);
} else {
// Browser environment - create download
const blob = new Blob([decodedContent], { type: 'text/javascript' });
const url = URL.createObjectURL(blob);
const a = 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 content
function analyzeDecodedContent(decodedContent) {
console.log('\n🔍 Content Analysis:');
console.log('- Total length:', decodedContent.length);
console.log('- Number of lines:', decodedContent.split('\n').length);
// Look for common patterns
const patterns = {
'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 names
const functionMatches = decodedContent.match(/function\s+(\w+)\s*\(/g);
if (functionMatches) {
const functionNames = functionMatches.map(match => match.match(/function\s+(\w+)/)[1]);
console.log('- Function names found:', functionNames);
}
return patterns;
}
// Main execution function
async function main() {
try {
console.log('🚀 Starting WikiVault content fetch and decode process...\n');
const result = await fetchAndDecodeWikiVault();
// Analyze the content
analyzeDecodedContent(result.decodedContent);
// Ask user if they want to save the file
if (typeof window !== 'undefined') {
// Browser environment
if (confirm('Would you like to download the decoded WikiVault script?')) {
saveDecodedContent(result.decodedContent);
}
} else {
// Node.js environment - save automatically
saveDecodedContent(result.decodedContent);
}
console.log('\n✅ Process completed successfully!');
return result;
} catch (error) {
console.error('\n❌ Process failed:', error.message);
// Provide troubleshooting suggestions
console.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 scripts
if (typeof module !== 'undefined' && module.exports) {
module.exports = {
fetchAndDecodeWikiVault,
decodeResponse,
saveDecodedContent,
analyzeDecodedContent,
main
};
}
// Auto-run if this script is executed directly
if (typeof window !== 'undefined' || (typeof require !== 'undefined' && require.main === module)) {
main();
}
// </nowiki>
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.