Program The rantings of a lunatic Scientist

Posts tagged as Chrome Extensions


Reddit Linker: A Chrome Extension for added sanity

Javascript Web Dev

I finally got sick enough of how Reddit opens Title links in the same tab to do something about it. I always took it as a given in Web Design that internal links opened in the same tab unless specified otherwise, and that external links always loaded in a new tab, so as to protect any possible progress the user may have had within your site/page against being lost… Which with Reddit, it is.

With Vanilla Reddit clicking a link opens it in the current tab, and backing up back to Reddit via the ‘back’ button does not take you to the same place in the page you left.

With the Reddit Enhancement Suite plugin, which features continuous scrolling the affect of this misalignment becomes much more frustrating. It is easy to have scrolled 30 virtual pages through Reddit, only to click a link without thinking and backup to find you are back on page 0. And that auto load images has been turned off.

Shift – X btw if anyone doesn’t know; it’s the same as clicking the Show/Hide Images button at the top of the page.

Anyway, I finally got sick of it and in 2 minutes I whipped up this handy little plugin for Google Chrome.

On page load it simply registers an event for whenever the page is altered. When this happens it sets a ‘timeout’ function to run in 100 milliseconds time.

Why in 100ms time? Because the event fires whenever the page is altered we don’t want it to fire for every little thing when lot of stuff happens. By waiting 100ms we are effectively saying…

If the page has changed, possibly multiple times, and now has become stable for 100ms then fix the page…

Here is the code for the plugin so you can see how simple it really is. The only additional thing that I left out of the code here is that in the Packaged Chrome Extension I prepended the Jquery .js file to the beginning of linker.js and then compiled the whole thing with Google’s Closure Compiler. Which is a very neat and powerful Javascript optimizer and minifier.