LebGeeks

A community for technology geeks in Lebanon.

You are not logged in.

#1 May 7 2016

samer
Admin

Open all new LebGeeks posts

As part of my moderating duties I review all the new posts on LebGeeks at least once a day.
If you find yourself manually clicking on "new posts" for every link in the new topics list, I wrote this simple bookmarklet a while back that some of you might find useful:

javascript:void%20function(){function%20openLink(el,index,array){window.open(el.href)}var%20links=document.querySelectorAll('a[href*=%22%26action=new%22]');links.forEach(openLink)}();

To use it, add it as a bookmark, navigate to the new posts page, then click on the bookmarklet. If there are multiple pages, you'll need to manually navigate through them and click the bookmarklet again.

Here's the uncompressed code for readability:

function openLink(el, index, array){
  window.open(el.href);
}

var links = document.querySelectorAll('a[href*="&action=new"]')

links.forEach(openLink);

I'm using a CSS3 selector to find all hyperlinks on a page that contain "&action=new" and opening them in a new tab.

I only tested in on Firefox, but it should work on all modern browsers.

Offline

#2 May 7 2016

rolf
Member

Re: Open all new LebGeeks posts

Thanks! It's easy to forget how much a little clever code can do.

I was hoping for an API or something like that (I'd have liked to play with it and extend lebgeeks), but if the URL parameters and HTML output are stable and minimal, that can be used directly, although it won't be future-proof.

Offline

#3 May 7 2016

NuclearVision
Member

Re: Open all new LebGeeks posts

Perhaps you could add a button somewhere under "topic: new, unanswered..."
that does the same thing.

Offline

#4 May 7 2016

bermudapineapple
Member

Re: Open all new LebGeeks posts

Useful. Thanks.

Offline

#5 May 8 2016

Georges00
Member

Re: Open all new LebGeeks posts

Could you implement that to the site?

Offline

#6 May 8 2016

samer
Admin

Re: Open all new LebGeeks posts

NuclearVision wrote:

Perhaps you could add a button somewhere under "topic: new, unanswered..."
that does the same thing.

Georges00 wrote:

Could you implement that to the site?

I would rather keep this out of the core code base for the time being to avoid adding visual clutter.

Offline

Board footer