User:Cörey/wikia.js

$('ul.tools li:first-child').before('Check User'); window.ajaxPages = ["Special:RecentChanges","Special:Watchlist","Special:Log","Special:Contributions","Special:WikiActivity"]; importScriptPage('AjaxRC/code.js', 'dev'); //Add link to Special:InterwikiEdit if (mw.config.get('wgPageName') === 'Community_Central:Interlanguage_link_requests') { $('#WikiaArticleCategories').before(''); document.getElementById("custom-interwiki-edit").innerHTML = ' Interwiki edit ' } /* Multiple Interwiki links - by Monchoman45 */ window.InterwikiEdit = { buffer: true, threads: 10, running: 0, queue: [] }; InterwikiEdit.onload = function { if (wgCanonicalSpecialPageName == 'InterwikiEdit' && !mw.util.getParamValue('action')) { var gui = document.createElement('div'); gui.innerHTML = 'Multiple List each domain (eg. ), one on each line. This will link each specified wiki to every other specified wiki.    '; document.getElementById('mw-content-text').appendChild(gui); } } $(InterwikiEdit.onload); InterwikiEdit.linkAll = function (wikis) { for (var i = 0; i < wikis.length - 1; i++) { for (var j = i + 1; j < wikis.length; j++) { if (wikis[i] != wikis[j]) { if (!InterwikiEdit.buffer || InterwikiEdit.running < InterwikiEdit.threads) { InterwikiEdit.link(wikis[i], wikis[j], InterwikiEdit.linkAllCallback); InterwikiEdit.running++; } else { InterwikiEdit.queue.push([wikis[i], wikis[j]]); }           } else { console.log(i + ' == ' + j); }       }    } } InterwikiEdit.link = function (wiki1, wiki2, callback) { if (!wiki1 || !wiki2) { return false; }   var get = new XMLHttpRequest; var url = '/wiki/Special:InterwikiEdit?action=Link&wikia=' + wiki1 + '.wikia.com&ext_wikia=' + wiki2 + '.wikia.com&useskin=wikia'; get.open('GET', url, true); get.onreadystatechange = function { if (this.readyState == 4 && this.status == 200) { var html = document.createElement('html'); html.innerHTML = this.responseText; var form = html.getElementsByTagName('form'); for (var i = 0; i < form.length; i++) { if (form[i].id == 'chooseaction') { form = form[i]; break; }           }            var post = new XMLHttpRequest; post.open('POST', url, true); post.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); post.onreadystatechange = function { if (this.readyState == 4 && this.status == 200 && typeof callback == 'function') { callback.call(this, wiki1, wiki2); }           }            post.send('action=commit_link&wikia_id=' + form['wikia_id'].value + '&ext_wikia_id=' + form['ext_wikia_id'].value); }   }    get.send; return get; } InterwikiEdit.linkAllCallback = function (wiki1, wiki2) { var output = document.getElementById('interwiki-multiple-output'); var scroll = false; if (output) { if (output.offsetHeight + output.scrollTop >= output.scrollHeight) { scroll = true; }       output.innerHTML += wiki1 + ' >=< ' + wiki2 + '\n'; }   if (InterwikiEdit.queue.length > 0) { wikis = InterwikiEdit.queue.shift; InterwikiEdit.link(wikis[0], wikis[1], InterwikiEdit.linkAllCallback); } else { InterwikiEdit.running--; if (InterwikiEdit.running == 0 && output) { output.innerHTML += '-\n'; }   }    if (scroll) { output.scrollTop = output.scrollHeight; } } if (wgCanonicalSpecialPageName == 'Chat') { $('Chat Connect Log').appendTo('.ChatHeader'); }