Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> [script] Convert popups into regular links

 
post Feb 7 2017, 01:03
Post #1
JukanX



Lurky McLurkFace
****
Group: Gold Star Club
Posts: 384
Joined: 8-July 09
Level 467 (Godslayer)


Edit 2017-02-08: added a version that opens popups in new tabs as per Blue Penguin's suggestion.

I've made a quick and dirty GreaseMonkey script for converting some links (as packaged, only Torrent/Gallery Download and Get External Gallery, but it's trivial to modify to suit one's preferences) from popups to regular links.

Can be useful if – like me – one downloads several torrents in a row, and dislikes then having to close both the tabs and the popup windows.


With (note back arrow working):
(IMG:[i.imgur.com] http://i.imgur.com/QTMxHVY.png)

Without (multiple torrent windows that I regularly forget to close)
(IMG:[imgur.com] http://imgur.com/Hs1xrsM.png)

Attached File  E_H___KillPopups.user.js.zip ( 866bytes ) Number of downloads: 56

Attached File  E_H___PopupsToTabs.user.js.zip ( 894bytes ) Number of downloads: 39


This post has been edited by JukanX: Feb 9 2017, 00:12
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Feb 7 2017, 01:22
Post #2
blue penguin



in umbra, igitur, pugnabimus
***********
Group: Gold Star Club
Posts: 10,045
Joined: 24-March 12
Level 500 (Godslayer)


ew... XPath

Still a good thing to have. May I suggest one little tweak?

CODE
  if (RealDestination) {
    elmAnchorPopUp.setAttribute('href', RealDestination);
    elmAnchorPopUp.removeAttribute('onclick');
  }
To:
CODE
  if (RealDestination) {
    elmAnchorPopUp.href = RealDestination;
    elmAnchorPopUp.target = '_blank';
    elmAnchorPopUp.removeAttribute('onclick');
  }
Should be (1) faster because the attribute does not need to get parsed at runtime (negligible I know (IMG:[invalid] style_emoticons/default/smile.gif) ) and, more importantly, (2) opens in a new tab by default.

Thread added to script index
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Feb 9 2017, 00:12
Post #3
JukanX



Lurky McLurkFace
****
Group: Gold Star Club
Posts: 384
Joined: 8-July 09
Level 467 (Godslayer)


Yeah, XPath syntax isn't exactly friendly. Actually I only used it because the (quite old) online resource I looked up about writing GreaseMonkey scripts put in its "Getting started" chapter [commons.oreilly.com] a section named "Master XPath expressions" and I duly obliged.
(IMG:[invalid] style_emoticons/default/biggrin.gif) (IMG:[invalid] style_emoticons/default/tongue.gif)

Probably rewriting the script to parse all the links in the gallery would work too and perhaps would make the script easier to port to browsers other than Firefox, but as the current version runs in one millisecond (likely even less but that's the resolution of the console timer), I'm not in a rush to experiment...

As for the default opening in a new tab, IMO it kind of defeats the purpose. There are already multiple ways* to open a specific link in a tab, versus just one** for the reverse. However since it's a single line addition I've made a separate version and added it to the opening post.

Thanks for the kind comments.



* middle click; control key + left click; long press/right click --> "open in a new tab".

** to my knowledge, to force a default-new-tab link to open in the current tab the only way is to drag the link and drop it on the tab or the address bar; easy with a mouse, fiddly with a touchpad, impossible on touch screens ...
User is offlineProfile CardPM
Go to the top of the page
+Quote Post


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 


Lo-Fi Version Time is now: 29th April 2024 - 19:41