Skip to content

Instantly share code, notes, and snippets.

@ymolliks
Last active December 6, 2022 19:22
Show Gist options
  • Save ymolliks/3e89f1464830f39f9a0f9187e0e33e7d to your computer and use it in GitHub Desktop.
Save ymolliks/3e89f1464830f39f9a0f9187e0e33e7d to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Youtube shorts redirect
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Medium > Scribe.rip redirect
// @author Fuim
// @match *://*.medium.com/*
// @icon https://www.google.com/s2/favicons?domain=medium.com
// @grant none
// @run-at document-start
// @license GNU GLPv2
// ==/UserScript==
var oldHref = document.location.href;
if (window.location.href.indexOf('medium.com') > -1) {
window.location.replace(window.location.toString().replace(/medium.com/, 'scribe.rip'));
}
window.onload = function() {
var bodyList = document.querySelector("body")
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (oldHref != document.location.href) {
oldHref = document.location.href;
console.log('location changed!');
if (window.location.href.indexOf('medium.com') > -1) {
window.location.replace(window.location.toString().replace(/medium.com/, 'scribe.rip'));
}
}
});
});
var config = {
childList: true,
subtree: true
};
observer.observe(bodyList, config);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment