Opening Reddit Links using Chrome Plugin

blogentry, programming, todayilearned, automation


title: Opening Reddit Links using Chrome Plugin date: "2017-06-25" banner: ./images/featured-image-2.jpg published_at: "2017-06-25T15:00:56.000Z" tags: "blogentry, programming, todayilearned, automation" author: Sung M. Kim

It was Saturday night. I had a lot of time on my hands so I decided to browse Reddit.

Reddit has so many links, clicking on each link manually was a burden to my hands and wasn't time efficient.

I decided to automate opening each link.

As mentioned, the first problem is that, I had to manually click each link on a page.

So I wrote a simple JavaScript to open links in Chrome developer console.

// Get reddit links
var divs = document.querySelectorAll('a[data-event-action="title"]');
// Open all links
for (i = 0; i < divs.length; i++) { window.open(divs[i].href); };
// Move to next page
window.location.href= document.querySelector('.next-button a').href;
view raw reddit.js hosted with ❤ by GitHub

But Chrome prevents JavaScript from opening multiple tabs. So I used Internet Explorer, which allows JavaScript to open multiple tabs.

A problem occurred when I went to other Sub-Reddits in a new tabs. I had to open developer console again and paste JavaScript.

I found out that Chrome Plugin allows opening multiple tabs using JavaScript. After implementing a simple plugin, I was able to open links with a click of a button.

The last problem is that, I didn't want to click the plugin every time. So I decided to bind the plugin with a keyboard shortcut.

Now I can open all links with a keyboard shortcut, Ctrl+Alt+F.


I was able to browse Reddit much faster than I could have had than clicking on each link manually.

There is already a Chrome plugin called Reddit Enhancement Suite (RES), which was pointed out by "Aaron C" on Coding Blocks Slack Channel.

This is a real handy plugin, which toggles all images in the main feed.