Skip to content

Instantly share code, notes, and snippets.

@therealFoxster
Last active September 21, 2022 18:41
Show Gist options
  • Save therealFoxster/982a91aeea4c053fb6a22d42f86274db to your computer and use it in GitHub Desktop.
Save therealFoxster/982a91aeea4c053fb6a22d42f86274db to your computer and use it in GitHub Desktop.
UserScript to filter public repositories by default on github.com
// ==UserScript==
// @name GitHub Filter Public Repositories
// @version 1.0.0
// @description Show public repositories by default
// @author Foxster
// @match *://github.com/*
// @compatible safari
// @grant GM.xmlHttpRequest
// @run-at document-start
// ==/UserScript==
let previousURL = "";
const observer = new MutationObserver(function(mutations) {
if (location.href !== previousURL) {
let url = new URL(location.href);
// If in "Repositories" tab and doesn't have "type" parameter
if (url.searchParams.get("tab") == "repositories" && !url.searchParams.get("type") && !location.href.includes("&type=")) {
location.href += "&type=public";
}
previousURL = location.href;
}
});
observer.observe(document, { subtree: true, childList: true });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment