Discussions » Creation Requests

force anchor links on a page to open in new tab?

§
Posted: 2017-12-07

force anchor links on a page to open in new tab?

is there any way to make this anchor open in new tab?

superbe.am

§
Posted: 2017-12-07
Edited: 2017-12-07

a class="" href="javascript:void(0)" onclick="viewtreeelement('subscription','45592063',1);focusit('1_45592063',true);">superbe.am

wOxxOmMod
§
Posted: 2017-12-08
§
Posted: 2017-12-08

I tried and it didn't work, I get a return in the first if statement, I don't know why is that

wOxxOmMod
§
Posted: 2017-12-08

You're probably using Greasemonkey 4, which is a bug fest. Try with Tampermonkey for Firefox, it works perfectly. If it doesn't for you, I would need a sample site URL to test it myself and see if I can fix the script.

§
Posted: 2017-12-08

I'm running GS 3.17, maybe because I'm on firefox esr 52.5.0, I think it has to do with the function? I tried with middle click as someone suggested and it shows javascript:void(0) in the address bar

wOxxOmMod
§
Posted: 2017-12-08

The script works for me in GM3.17 + FF52.5. Like I said, I would need a sample site URL to test it myself and see if I can fix the script.

wOxxOmMod
§
Posted: 2017-12-08

Ah, I see the script intentionally skips javascript: links. Try editing the script code and remove the following line:

        (link.getAttribute('href') || '').match(/^(javascript|#|$)/) ||
§
Posted: 2017-12-08

thanks for the support,

still goes into this:
if (e.button > 1 || e.altKey || e.target != clickedElement)
return;
var link = e.target.closest('a');
if (!link ||
link.href.replace(/#.*/, '') == location.href.replace(/#.*/, '')
)
alert('1');
return;

have you heard of inoreader?
this is the url:
https://www.inoreader.com/dashboard

you may need an account and then go over to dashboard url and click on a link on recommended sources for example

wOxxOmMod
§
Posted: 2017-12-08

What about this:

// ==UserScript==
// @name         Open jQuery links in new tab
// @match        https://www.inoreader.com/feed/*
// @grant        none
// ==/UserScript==

window.addEventListener('load', () => {
  const listeners = (window.jQuery && jQuery._data(document, 'events') || {}).mousedown || [];
  listeners.splice(listeners.findIndex(({handler}) => /article_content/.test(handler)), 1);

  window.addEventListener('mousedown', event => {
    const a = event.target.closest('a');
    if (!a)
      return;
    a.onmousedown = null;
    a.target = '_blank';
  }, true);

}, {once: true});
§
Posted: 2017-12-08

it didn't work either...

maybe you should try the url/site yourself, or include debugging code for me to see what happens..

wOxxOmMod
§
Posted: 2017-12-08

Well, it worked for me...

§
Posted: 2017-12-08

maybe you pressed (and the code refers to) an article? I want the subscriptions to open in a new tab, not the articles

wOxxOmMod
§
Posted: 2017-12-08

Subscriptions is not a link, it's dynamically constructed by the inoreader page script, there's simply nothing to open in a new tab.

§
Posted: 2017-12-08

no you still didn't understand, I meant a specific subscription, not the subscriptions you see on the left pane, if you've never used inoreader before, search for a subject in the top left search field, subscribe to it and then go to the dashboard (again left pane, on the bottom) and look for suggestions/suggested subscriptions, something like that and try to push that, it's an anchor like the one I posted on the second post

wOxxOmMod
§
Posted: 2017-12-08

yeah I have no idea what you're talking about, just tried in FF and Chrome and there's no <a> link with that excerpt you posted originally.

image

§
Posted: 2017-12-08

here it is

wOxxOmMod
§
Posted: 2017-12-08
Edited: 2017-12-08

Despite <a> element being used (bad programming decision), that's not a link to a page. It just builds the feed's UI using page script.

§
Posted: 2017-12-08

ahh, ok, I see, thanks again for your help

Post reply

Sign in to post a reply.