Skip to content

Instantly share code, notes, and snippets.

@makotom
Created September 10, 2011 01:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save makotom/1207767 to your computer and use it in GitHub Desktop.
Save makotom/1207767 to your computer and use it in GitHub Desktop.
UserJS to omit redirections in 2ch BBS.
addEventListener("DOMContentLoaded", function(){
if(location.hostname.indexOf(".2ch.net", location.hostname.length - ".2ch.net".length) === -1) return;
var a = document.getElementsByTagName("a"), i;
for(i = 0; i < a.length; i += 1) a[i].href = a[i].href.replace(/:\/\/ime\.nu\//, "://");
}, false);
@tagawa
Copy link

tagawa commented Feb 2, 2012

You should definitely make this into an extension!

Just a couple of things you could change if you like:

addEventListener("DOMContentLoaded", function(){
    if(location.hostname !== '2ch.net') return;

    var a = document.getElementsByTagName("a"), i;
    for(i = 0; i < a.length; i += 1){
        a[i].href = a[i].href.replace(/:\/\/ime\.nu\//, "://");
    }
}, false);

(not tested)

@makotom
Copy link
Author

makotom commented Feb 2, 2012

@tagawa
Good. I will employ your idea :)

@makotom
Copy link
Author

makotom commented Feb 2, 2012

I found out that String.indexOf is slightly faster than String.match. Interesting.

@makotom
Copy link
Author

makotom commented Feb 2, 2012

Applied more updates to hostname matching, according to my speed test (http://tomato.myftp.org/blog/post?id=186).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment