Skip to content

Instantly share code, notes, and snippets.

@ryuya0124
Last active December 31, 2023 16:05
Show Gist options
  • Save ryuya0124/063e908398408226934a71da00b2c582 to your computer and use it in GitHub Desktop.
Save ryuya0124/063e908398408226934a71da00b2c582 to your computer and use it in GitHub Desktop.
All Open in Chrome (Exclude Twitter and YouTube)
// ==UserScript==
// @name All Open in Chrome (Exclude Twitter and YouTube)
// @version 1.0.2
// @match *://*/*
// @exclude *://twitter.com/*
// @exclude *://www.youtube.com/*
// @exclude *://t.co/*
// @exclude *//www.signum.fun/*
// @exclude *//accounts.google.com/*
// @exclude https://www.instagram.com/*
// @downloadURL https://gist.github.com/ryuya0124/063e908398408226934a71da00b2c582/raw/ed254d706e7379aa1c8a70e8aa5950ed6a3d19bb/Open-HTTPS-in-Chrome.user.js
// @updateURL https://gist.github.com/ryuya0124/063e908398408226934a71da00b2c582/raw/ed254d706e7379aa1c8a70e8aa5950ed6a3d19bb/Open-HTTPS-in-Chrome.user.js
// @homepage https://gist.github.com/ryuya0124/063e908398408226934a71da00b2c582
// ==/UserScript==
if (window.location.pathname === '/redirect') return;
const currentHost = window.location.hostname;
const excludedHosts = ['twitter.com', 'www.youtube.com', 't.co', 'www.signum.fun', 'accounts.google.com', 'www.instagram.com'];
let urlToOpen;
// Check if the current host is not excluded and www is not present
if (!excludedHosts.includes(currentHost) || !currentHost.startsWith('www.')) {
urlToOpen = window.location.href.replace(/^https?:\/\//, 'googlechrome://');
window.location.href = urlToOpen;
} else {
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment