-
-
Save radiantly/e1c7319214c77fa007f323fc56cd0239 to your computer and use it in GitHub Desktop.
// ==UserScript== | |
// @name Prevent link mangling on Google | |
// @namespace LordBusiness.LMG | |
// @match https://www.google.com/search | |
// @grant none | |
// @version 1.1 | |
// @author radiantly | |
// @description Prevent google from mangling the link when copying or clicking the link on Firefox | |
// ==/UserScript== | |
/* | |
* If you're on Firefox, you might have noticed that when you try to click (or copy) a link from | |
* a google search result, it redirects to an intermediate page instead of taking you immediately | |
* to the search result. This is specifically annoying when trying to copy a google search result | |
* to send to someone else, because it gives you the mangled google-ified link instead. | |
* | |
* The same does not happen on Google Chrome or other chromium browsers. Maybe someone can test | |
* this on Safari? | |
* | |
* To install this script, you'll need a user script manager like ViolentMonkey, after which you | |
* can click the Raw button (gist.github.com) to install. | |
*/ | |
(function() { | |
/* | |
* The following 3 lines simply prevent the mousedown event from propagating to the respective | |
* event listeners attached to the various link elements. | |
* | |
* On testing, this does not seem to break any actual functionality on the site. | |
*/ | |
window.addEventListener("mousedown", (event) => { | |
event.stopImmediatePropagation(); | |
}, true); | |
})(); |
Thanks, this is so useful!
It happens on the standard version of Firefox but not on Firefox Nightly, maybe the problem is not Google itself
On TamperMonkey, I managed to make it work with the @include
statement instead of @match
// @include https://www.google.com/search*
UPD: Thanks for the great script!
This is not working for me - I installed with GreaseMonkey on FF 92.0.1 and GM says the script is enabled, but copying links from google search results still results in that intermediate URL. Suggestions?
EDIT: Ok, just saw @qezz's comment - making that change fixed it for me.
Any way to do this on iOS Safari? Perhaps with their new extension API?
Update: The bookmarklet works, but is needs to be triggered each time manually which sucks.
Also, you may also want other regional sites of Google to be included:
(co*
instead of com*
is a workaround for google.co.jp
)
// @match https://www.google.co*/search
(P.S. Check qezz's comment if this does not work)
Thanks for sharing the script, I had found some vanilla methods that also work on firefox 104 which I thought to share here.
i) Right faraway method posted by benczur
"Right-click and hold" on some empty space away from the link. Move your mouse pointer (with right button still depressed) over the link. Release right-click and select 'Copy link location/shortcut'.(Credit to stormenet.)
ii) Inspector method posted by falconepl
Just activate the inspector tool (Shift+Ctrl+C shortcut), then right-click on a given link within Google Search results and select Copy Link Location. Because you've got the inspector tool activated, it would prevent Google's script from replacing original link's location with their own.
One reason I would highly recommend DuckDuckGo (and the
ddgr
CLI). You could also use thegoogler
CLI.