User talk:Tom/Greasemonkey Script

From Homestar Runner Wiki

(Difference between revisions)
Jump to: navigation, search
m (Meant to link to ween stuff.)
m (Adding a reduced form of the script.)
Line 1: Line 1:
-
Hm, I would hate to have to reinstall this script every time there's a new toon on HR.com. In the interest of automation, would it be better to have the Greasemonkey script simply pick up the filename of the page it's sitting on? We've already created redirects such as [[sbemail1]], [[sbemail2]], etc. Why not create redirects from every other filename as well (like [[ween05]], [[main7]], etc.) and just have the Greasemonkey script send people to the wiki page for each filename? Does this make any sense? — {{User:JoeyDay/sig}} 22:01, 31 October 2005 (UTC)
+
Hm, I would hate to have to reinstall this script every time there's a new toon on HR.com. In the interest of automation, would it be better to have the Greasemonkey script simply pick up the filename of the page it's sitting on? We've already created redirects such as [[sbemail1]], [[sbemail2]], etc. Why not create redirects from every other filename as well (like [[ween05]], [[main7]], etc.) and just have the Greasemonkey script send people to the wiki page for each filename?  
 +
 
 +
Then the script would be reduced to the following:
 +
 
 +
<pre>// ==UserScript==
 +
// @name Homestar Runner - Add hrwiki.org links.
 +
// @namespace http://www.hrwiki.org/index.php/User:Tom/Greasemonkey_Script
 +
// @description Adds links to Homestar Runner Wiki articles from homestarrunner.com toons, etc.
 +
// @include http://www.homestarrunner.com/*.html
 +
// @include http://homestarrunner.com/*.html
 +
 
 +
// ==/UserScript==
 +
 
 +
(function() {
 +
 
 +
  var file = window.location.pathname;
 +
  var a = document.createElement('a');
 +
 
 +
    var div = document.createElement("div");
 +
 +
a.href = "http://www.hrwiki.org/index.php/" + file;
 +
a.appendChild(document.createTextNode('Homestar Runner Wiki article'));
 +
div.appendChild(a);
 +
div.setAttribute("style", "text-align: left; left: 1px; bottom: 1px; background-color: white; padding: 2px 5px; position: absolute; z-index: 100;");
 +
document.body.insertBefore(div, document.body.firstChild);
 +
  }
 +
   
 +
)();</pre>
 +
 
 +
Then, instead of having to update the script each time a new toon comes out, we just have to build a new redirect from the filename to the appropriate article. {{User:JoeyDay/sig}} 22:01, 31 October 2005 (UTC)

Revision as of 22:51, 31 October 2005

Hm, I would hate to have to reinstall this script every time there's a new toon on HR.com. In the interest of automation, would it be better to have the Greasemonkey script simply pick up the filename of the page it's sitting on? We've already created redirects such as sbemail1, sbemail2, etc. Why not create redirects from every other filename as well (like ween05, main7, etc.) and just have the Greasemonkey script send people to the wiki page for each filename?

Then the script would be reduced to the following:

// ==UserScript==
// @name		Homestar Runner - Add hrwiki.org links.
// @namespace		http://www.hrwiki.org/index.php/User:Tom/Greasemonkey_Script
// @description		Adds links to Homestar Runner Wiki articles from homestarrunner.com toons, etc.
// @include		http://www.homestarrunner.com/*.html
// @include		http://homestarrunner.com/*.html

// ==/UserScript==

(function() {
   
  var file = window.location.pathname;
  var a = document.createElement('a');

    var div = document.createElement("div");
	
	a.href = "http://www.hrwiki.org/index.php/" + file;
	a.appendChild(document.createTextNode('Homestar Runner Wiki article'));
	div.appendChild(a);
	div.setAttribute("style", "text-align: left; left: 1px; bottom: 1px; background-color: white; padding: 2px 5px; position: absolute; z-index: 100;");
	document.body.insertBefore(div, document.body.firstChild);
  }
    
)();

Then, instead of having to update the script each time a new toon comes out, we just have to build a new redirect from the filename to the appropriate article. wikisig.gif Joey (talk·edits) 22:01, 31 October 2005 (UTC)