Jump to content

User:T3h 1337 b0y/vector.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by T3h 1337 b0y (talk | contribs) at 05:56, 20 June 2010. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
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.
importScript('User:Pyrospirit/metadata/assesslinks.js'); //[[User:Pyrospirit/metadata/assesslinks.js]]

importScript('User:Ale_jrb/Scripts/igloo.js'); // [[User:Ale_jrb/Scripts/igloo]]
/************* *** Regex menu framework *** by [[m:user:Pathoschild]] <http://meta.wikimedia.org/wiki/User:Pathoschild/Scripts/Regex_menu_framework> ***	- adds a sidebar menu of user-defined scripts. *************/ importScriptURI('http://meta.wikimedia.org/w/index.php?title=User:Pathoschild/Scripts/Regex_menu_framework.js&action=raw&ctype=text/javascript');  /* menu links */ // In the function below, add more lines like "regexTool('link text','function_name()')" to add // links to the sidebar menu. The function name is the function defined in rfmscripts() below. function rmflinks() { 	regexTool('Custom regex','custom()'); // a default tool which performs regex input in a dynamic form }  /* scripts */ // Below, define the functions linked to from rmflinks() above. These functions can use any JavaScript, // but there is a set of simplified tools documented at // http://meta.wikimedia.org/wiki/User:Pathoschild/Script:Regex_menu_framework .
// ==UserScript== // @name         WP:Deredirectification // @description  Changes the text of the title of hyperlinks that are redirects to the title of the target of the redirect : // @include      http://*.wikipedia.org/wiki/* // @include      http://*.wikimedia.org/wiki/* // ==/UserScript==  // extracted from json.js (http://www.json.org/json.js ) //    which is Copyright © 2002 JSON.org (go read http://www.json.org/license.html ) String.prototype.parseJSON = function () { try { return !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test( this.replace(/"(\\.|[^"\\])*"/g, ''))) && eval('(' + this + ')'); } catch (e) { return false; } };  var logging = 0; //increment for GM_log diarrhoea!  var titles = []; var A = document.getElementsByTagName("A"); for (var i = 0; i < A.length; i++) if ((/^[A-Z][A-Za-z]?:/.test(A[i].title)) && (titles.indexOf(A[i].title) < 0)) titles.push(A[i].title); titles.sort(); //not necessary, but pretty! : if (logging > 0) {GM_log(titles.length + "| " + titles);}  // this is the onload callback function for the GM_xmlhttpRequest function BANZAI(response) { if (logging > 0) {GM_log("status: " + response.status);} if (logging > 1) {GM_log("status text: " + response.statusText);} if (logging > 1) {GM_log("response headers:\n" + response.responseHeaders);} if (logging > 1) {GM_log("response text:\n" + response.responseText);} if (response.status != 200) throw ("You Have Angered The Cabal!\n" + "Try Again In " + response.status + " Years."); var yurik = response.responseText.parseJSON(); if (yurik == false) throw ("I Smell A Wumpus!\n" + "Response Isn't JSON."); if (yurik.error) throw ("Beware Of Developers Wielding Cluebats!\n" + "Your Error Was \"" + yurik.error.* + "\"."); var redirects = {}; for (var id in yurik.pages) { var title = yurik.pages[id].title; if (yurik.pages[id].redirect != undefined && yurik.pages[id].redirect.to != undefined) { var redirect = yurik.pages[id].redirect.to.*; redirects[title] = redirect; if (logging > 2) {GM_log(title + " ’ " + redirect);} } } var A = document.getElementsByTagName("A"); for (var i = 0; i < A.length; i++) if (redirects[A[i].title] != undefined) A[i].title = redirects[A[i].title]; }  var URL = "http://" + document.domain + "/w/query.php" //query the right server! URL += "?noprofile"; //Don't care URL += "&format=json"; //JSON FTW URL += "&what=redirects"; //important URL += "&titles="; //This gets tacked on later ´  if (titles.length > 0) //avoid an empty query { //OK, so WP:WP has like 432 redirect links on it, // which makes shit fly when you stuff all that into one query //Soooo& now we split large queries into chunks and make multiple requests var chunk = 100; for (var k = 0; k < titles.length; k += chunk) { var request = {method: "GET", onload: BANZAI}; request.headers = { "Accept": "application/json", }; request.url = encodeURI(URL + titles.slice(k, k + chunk).join('|')) if (logging > 1) {GM_log(request.url );} GM_xmlhttpRequest(request); } }