Skip to content

Instantly share code, notes, and snippets.

@jarp0l
Created March 24, 2024 12:11
Show Gist options
  • Select an option

  • Save jarp0l/a43cb4077334780667e184bc505cf276 to your computer and use it in GitHub Desktop.

Select an option

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/*`
// ==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