Bitcoin Forum
October 18, 2019, 05:31:02 AM *
News: Latest Bitcoin Core release: 0.18.1 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: [Userscript] Automatically append ;dt to the end of URLs (View as DT) [v0.2.3]  (Read 151 times)
DarkStar_
Legendary
*
Online Online

Activity: 1484
Merit: 2038


https://bitcoin.watfordfc.com


View Profile WWW
January 13, 2019, 04:14:03 AM
Last edit: January 13, 2019, 05:50:04 PM by DarkStar_
Merited by Vod (10), suchmoon (7), Hhampuz (2), o_e_l_e_o (2), OgNasty (1), coinlocket$ (1), Coolcryptovator (1)
 #1

I made a basic Userscript that will automatically add ";dt" to the end of all[1] bitcointalk URLs. It basically acts as a "View as DefaultTrust" option and can be toggled in Tampermonkey.

Installation:
1. Install the Tampermonkey extension (firefox) (chrome) if it is not already installed.
2. Click here and click the "Install" button (current version: 0.2.3)

Usage:
1. Install
2. Enjoy!
3. You can disable the script by unchecking the DT Redirect box in Tampermonkey.

Source Code:
The source code can be found here.

Changelog:
Code:
v0.1.0 - Released
v0.2.0 - Changed to inject URLs with ;dt to prevent needless redirects
v0.2.1 - Adds injection where URL contains only the path
v0.2.2 - Prevents URLs containing only paths from being injected on sites other than Bitcointalk
v0.2.3 - Injects URLs with a path of both "/index.php" and "index.php"

Disclaimer:
I am not liable for any damages somehow caused by the script.


[1] Not all URLs are redirected, as some pages break when ;dt is added. Currently, links to direct messages (example) and links that lead to the newest post (example) are excluded as they do not directly lead to a specific message when ;dt is appended. Some other links are excluded as well, but adding ;dt would have no effect on those pages. If there are other pages that break, please let me know and I will exclude them from the script.

1571376662
Hero Member
*
Offline Offline

Posts: 1571376662

View Profile Personal Message (Offline)

Ignore
1571376662
Reply with quote  #2

1571376662
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1571376662
Hero Member
*
Offline Offline

Posts: 1571376662

View Profile Personal Message (Offline)

Ignore
1571376662
Reply with quote  #2

1571376662
Report to moderator
suchmoon
Legendary
*
Offline Offline

Activity: 2100
Merit: 4099


Pedal-powered plaguebot


View Profile
January 13, 2019, 04:30:34 AM
 #2

Is this going to load each page twice?

DarkStar_
Legendary
*
Online Online

Activity: 1484
Merit: 2038


https://bitcoin.watfordfc.com


View Profile WWW
January 13, 2019, 04:33:54 AM
 #3

Is this going to load each page twice?

Unfortunately I believe it does. I'm not sure if the first page is actually loaded, but it does redirect in the browser. The alternative would be to inject modifications to URLs, but I'm not too sure how to do it.

suchmoon
Legendary
*
Offline Offline

Activity: 2100
Merit: 4099


Pedal-powered plaguebot


View Profile
January 13, 2019, 04:41:00 AM
Merited by DarkStar_ (7)
 #4

Is this going to load each page twice?

Unfortunately I believe it does. I'm not sure if the first page is actually loaded, but it does redirect in the browser. The alternative would be to inject modifications to URLs, but I'm not too sure how to do it.

Code:
document.querySelectorAll("a[href^='https://bitcointalk.org/']").forEach(a => { a.href += ";dt"; });

Well, you probably want to do more validation, e.g. if the URL already has ";dt" in it for some reason, plus your exclusions.

DarkStar_
Legendary
*
Online Online

Activity: 1484
Merit: 2038


https://bitcoin.watfordfc.com


View Profile WWW
January 13, 2019, 05:21:23 AM
 #5

Is this going to load each page twice?

Unfortunately I believe it does. I'm not sure if the first page is actually loaded, but it does redirect in the browser. The alternative would be to inject modifications to URLs, but I'm not too sure how to do it.

Code:
document.querySelectorAll("a[href^='https://bitcointalk.org/']").forEach(a => { a.href += ";dt"; });

Well, you probably want to do more validation, e.g. if the URL already has ";dt" in it for some reason, plus your exclusions.

Thanks, version 0.2 injects URLs instead now.

Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!