There are 10 previous versions of this script.
// ==UserScript==
// @name changeLinks
// @namespace tag:a_hal89@hotmail.com,2008-05-22:Ahal
// @description Allows you to modify most Links and Buttons anywhere
// @include http://*.google.*
// ==/UserScript==
/* This script will also work on other predominantly text-based websites.
Simply include the site you wish to edit the link in, and carry on as normal.
*/
/* Do not modify this unless you know what you're doing */
var link=document.evaluate("//a[@href]", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
var button=document.evaluate("//input[@value]", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
/* UnComment and change this to whatever you want the page to be called.
This shows up at the top of the browser and on the tab.
Leave it commented to use the page default titles.
*/
//document.title = "";
/* ---Instructions for Beginners---
1. Find a link or button on Google (or another site you included) that you wish to change.
2. If it is a button, go to the button section. If it is a link, go to the link section.
3. Copy the template function call, and paste it on the line below.
4. Modify the first String (inside the "" marks) to the name of the link or button on the webpage. It is case sensitive.
5. Alternatively modify this string to be the link's href property, regex's are recommended when doing this.
6. Modify the second String to what you want the link to say.
7. Modify the third String to the location you want the link to point, make sure to include http://
8. Leave the field blank ("") if you wish it to remain unchanged.
9. The last parameter is optional, if you want to use regular expressions to search for a match instead of plain text, set this to 1.
10. Here is an example which will change the 'About Google' link to say 'Facebook!!!', and when clicked will bring you to facebook:
modifyLink ("About Google", "Facebook!!!", "http://www.facebook.com", 0)
*/
/* ---Link Section--- */
modifyLink ("Actual Link Text (or link href)", "Desired Link Text", "Desired Link Path", 0);
/* ---Button Section--- */
modifyButton ("Actual Button Text", "Desired Button Text", 0);
/* Do not modify the section below unless you know what you're doing */
function modifyLink (ExpectedName, DesiredName, DesiredTarget, RegexEnabled){
if (RegexEnabled != 1){
toReplace = /(\/|\.|\*|\+|\?|\||\(|\)|\[|\]|\{|\}|\\|\^|\$)/g;
ExpectedName = ExpectedName.replace(toReplace, "\\$1");
ExpectedName = "^" + ExpectedName + "$";
}
re = new RegExp(ExpectedName)
for(i = 0; i < link.snapshotLength; i++) {
tmp = link.snapshotItem(i);
if(re.test(tmp.innerHTML)){
if (DesiredName != ""){
tmp.innerHTML = DesiredName;
}
if (DesiredTarget != ""){
tmp.href = DesiredTarget;
}
}
else if(re.test(tmp.href)){
if (DesiredName != ""){
tmp.innerHTML = DesiredName;
}
if (DesiredTarget != ""){
tmp.href = DesiredTarget;
}
}
}
}
function modifyButton (ExpectedName, DesiredName, RegexEnabled){
if (RegexEnabled != 1){
toReplace = /(\/|\.|\*|\+|\?|\||\(|\)|\[|\]|\{|\}|\\|\^|\$)/g;
ExpectedName = ExpectedName.replace(toReplace, "\\$1");
ExpectedName = "^" + ExpectedName + "$";
}
re = new RegExp(ExpectedName)
for(i = 0; i < button.snapshotLength; i++) {
tmp = button.snapshotItem(i)
if(re.test(tmp.value)){
if (DesiredName != ""){
tmp.value = DesiredName;
}
}
}
}
// ==/UserScript==
