// ==UserScript== // @name GitHub Milestones Redirect // @namespace http://tampermonkey.net/ // @version 1.0 // @description Redirects to GitHub milestones with specific parameters on link click // @author You // @match https://github.com/* // @grant none // ==/UserScript== (function() { 'use strict'; function isGitHubMilestoneURL(url) { const urlPattern = /^https:\/\/github\.com\/[^\/]+\/[^\/]+\/milestones$/; return urlPattern.test(url); } // Function to handle the link click event function handleLinkClick() { const u = new URL(window.location.href).pathname.split('/').filter(v => v); const user = u[0] const repo = u[1] if (isGitHubMilestoneURL(window.location.href)) { // Redirect to the specified URL window.location.href = `https://github.com/${user}/${repo}/milestones?direction=asc&sort=due_date&state=open` } } handleLinkClick() var oldHref = document.location.href; window.onload = function() { var bodyList = document.querySelector("body") var observer = new MutationObserver(function(mutations) { if (oldHref != document.location.href) { oldHref = document.location.href; /* Changed ! your code here */ handleLinkClick() } }); var config = { childList: true, subtree: true }; observer.observe(bodyList, config); }; })();