Created
March 24, 2024 12:11
-
-
Save jarp0l/a43cb4077334780667e184bc505cf276 to your computer and use it in GitHub Desktop.
Tampermonkey script to remove `?usp=sharing` param from Google Drive links on `https://bctengineeringnotes.blogspot.com/*`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Remove ?usp=sharing param | |
| // @namespace http://tampermonkey.net/ | |
| // @version 2024-03-24 | |
| // @description Remove ?usp=sharing param from Google Drive links | |
| // @author jarp0l | |
| // @match https://bctengineeringnotes.blogspot.com/* | |
| // @icon https://www.google.com/s2/favicons?sz=64&domain=blogspot.com | |
| // @grant none | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| // Get all 'a' tags without a class | |
| const anchorElements = document.querySelectorAll('a:not([class])'); | |
| // Iterate through each 'a' tag | |
| anchorElements.forEach((anchor) => { | |
| // Check if the href attribute contains the specified pattern | |
| if (anchor.href && anchor.href.includes('https://drive.google.com/file/d/')) { | |
| // Remove the '?usp=sharing' query parameter | |
| anchor.href = anchor.href.replace(/\?usp=sharing$/, ''); | |
| } | |
| }); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment