Last active
December 2, 2025 12:24
-
-
Save lalibi/b08de28db17eab05b86c038c5f32f62d to your computer and use it in GitHub Desktop.
Google /url redirect skipper
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 Google /url redirect skipper | |
| // @namespace https://lalibi.dev/ | |
| // @version 0.1.1 | |
| // @description Automatically redirect from Google's /url wrapper to the real target URL | |
| // @author lalibi | |
| // @match https://www.google.com/url* | |
| // @match https://www.google.*/url* | |
| // @run-at document-start | |
| // @grant none | |
| // @downloadURL https://gist.githubusercontent.com/lalibi/b08de28db17eab05b86c038c5f32f62d/raw/ | |
| // @updateURL https://gist.githubusercontent.com/lalibi/b08de28db17eab05b86c038c5f32f62d/raw/ | |
| // @icon https://www.google.com/s2/favicons?sz=128&domain=google.com | |
| // ==/UserScript== | |
| (function () { | |
| 'use strict'; | |
| // Support Google's most common param names that hold the real URL | |
| const params = new URLSearchParams(window.location.search); | |
| const candidateParams = ['q', 'url', 'continue']; | |
| let target = null; | |
| for (const key of candidateParams) { | |
| const value = params.get(key); | |
| if (value) { | |
| target = value; | |
| break; | |
| } | |
| } | |
| if (!target) { | |
| return; // nothing to do | |
| } | |
| try { | |
| // In case it's URL-encoded | |
| target = decodeURIComponent(target); | |
| } catch (e) { | |
| // ignore decode errors, just try the raw value | |
| } | |
| // Simple sanity check: require a scheme like http/https | |
| if (!/^https?:\/\//i.test(target)) { | |
| return; | |
| } | |
| // Replace so that the /url page doesn't stay in history | |
| window.location.replace(target); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment