Greasy Fork is available in English.

Diskusie » Žiadosť o vytvorenie

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

§
Pridaný: 07.12.2017

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

§
Pridaný: 07.12.2017
Upravený: 07.12.2017

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

wOxxOmZablokovaný
§
Pridaný: 08.12.2017
§
Pridaný: 08.12.2017

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

wOxxOmZablokovaný
§
Pridaný: 08.12.2017

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.

§
Pridaný: 08.12.2017

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

wOxxOmZablokovaný
§
Pridaný: 08.12.2017

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.

wOxxOmZablokovaný
§
Pridaný: 08.12.2017

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

        (link.getAttribute('href') || '').match(/^(javascript|#|$)/) ||
§
Pridaný: 08.12.2017

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

wOxxOmZablokovaný
§
Pridaný: 08.12.2017

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});
§
Pridaný: 08.12.2017

it didn't work either...

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

wOxxOmZablokovaný
§
Pridaný: 08.12.2017

Well, it worked for me...

§
Pridaný: 08.12.2017

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

wOxxOmZablokovaný
§
Pridaný: 08.12.2017

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

§
Pridaný: 08.12.2017

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

wOxxOmZablokovaný
§
Pridaný: 08.12.2017

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

§
Pridaný: 08.12.2017

here it is

wOxxOmZablokovaný
§
Pridaný: 08.12.2017
Upravený: 08.12.2017

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.

§
Pridaný: 08.12.2017

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

Pridať odpoveď

Aby ste mohli pridať odpoveď, prihláste sa.