diff --git a/README.md b/README.md index 6e65cb7..bab0332 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,23 @@ Make sure you have the Tampermonkey browser extension installed -Navigate to any script you desire in this repo and click the `Raw` button. Tampermonkey should take over and offer to (re)install it for you. From then on, you will have automatic updates from the main branch of this repo enabled by default. +Navigate to any script you desire and click the `Raw` button. Tampermonkey should take over and offer to (re)install it for you. From then on, you will have automatic (prompted) updates from that URL enabled by default. +# Maintained by ex-GreenSyncer @ZimbiX: -# Useful external scripts +- [Buildkite: Add app build & environments pipeline links on pipelines of GreenSync projects](https://github.com/ZimbiX/userscripts/blob/master/js/Buildkite%3A%20Add%20app%20build%20%26%20environments%20pipeline%20links%20on%20pipelines%20of%20GreenSync%20projects.user.js) +- [Buildkite: Expand logs sections automatically](https://github.com/ZimbiX/userscripts/blob/master/js/Buildkite%3A%20Expand%20logs%20sections%20automatically.user.js) +- [GitHub: Make TOC popup bigger](https://github.com/ZimbiX/userscripts/blob/master/js/GitHub%3A%20Make%20TOC%20popup%20bigger.user.js) +- [Google Drive: Switch to company Google account upon access denied](https://github.com/ZimbiX/userscripts/blob/master/js/Google%20Drive%3A%20Switch%20to%20company%20Google%20account%20upon%20access%20denied.user.js) +- [Google Meet: Switch to company account by default](https://github.com/ZimbiX/userscripts/blob/master/js/Google%20Meet%3A%20Switch%20to%20company%20account%20by%20default.user.js) +- [Pop: Auto-close session join tab](https://github.com/ZimbiX/userscripts/blob/master/js/Pop%3A%20Auto-close%20session%20join%20tab.user.js) +- [ZenHub: Highlight unchanged repo during issue creation](https://github.com/ZimbiX/userscripts/blob/master/js/ZenHub%3A%20Highlight%20unchanged%20repo%20during%20issue%20creation.user.js) +- [ZenHub: Link from board card titles to GitHub issues](https://github.com/ZimbiX/userscripts/blob/master/js/ZenHub%3A%20Link%20from%20board%20card%20titles%20to%20GitHub%20issues.user.js) +- [ZenHub: Redirect from issue to GitHub issue](https://github.com/ZimbiX/userscripts/blob/master/js/ZenHub%3A%20Redirect%20from%20issue%20to%20GitHub%20issue.user.js) - * [Changing Github relative time to exact time](https://github.com/Mottie/GitHub-userscripts/wiki/GitHub-static-time). +> @ZimbiX: Note that I am not currently using Buildkite or ZenHub, so probably won't notice any breakage. Issues and pull requests welcome however! =) + +# Other useful external scripts + +- [Changing Github relative time to exact time](https://github.com/Mottie/GitHub-userscripts/wiki/GitHub-static-time) +- [Wide GitHub](https://github.com/xthexder/wide-github) (only keep enabled when needed) diff --git a/buildkite/auto-expand-logs.user.js b/buildkite/auto-expand-logs.user.js deleted file mode 100644 index 1c39cb2..0000000 --- a/buildkite/auto-expand-logs.user.js +++ /dev/null @@ -1,21 +0,0 @@ -// ==UserScript== -// @name Buildkite: Expand logs sections automatically -// @namespace http://tampermonkey.net/ -// @version 0.1 -// @description try to take over the world! -// @author Brendan Weibrecht -// @match https://buildkite.com/gs/*/builds/* -// @icon https://www.google.com/s2/favicons?sz=64&domain=buildkite.com -// @grant none -// ==/UserScript== - -(function() { - 'use strict'; - - const expandLogsSections = () => { - document.querySelectorAll('.fa-caret-right').forEach((e) => { e.click() }) - setTimeout(expandLogsSections, 100); - } - - expandLogsSections(); -})(); diff --git a/buildkite/build-and-env-links.user.js b/buildkite/build-and-env-links.user.js deleted file mode 100644 index 3df7594..0000000 --- a/buildkite/build-and-env-links.user.js +++ /dev/null @@ -1,93 +0,0 @@ -// ==UserScript== -// @name Buildkite: Build and Env links on pipelines -// @description Add app build & environments pipeline links on pipelines of GreenSync projects -// @namespace http://tampermonkey.net/ -// @version 0.2 -// @author Brendan Weibrecht -// @match https://buildkite.com/gs/* -// @icon https://www.google.com/s2/favicons?sz=64&domain=buildkite.com -// @grant none -// ==/UserScript== - -(() => { - 'use strict'; - - const urlMatch = window.location.href.match(new RegExp("https://buildkite.com(/gs/[^/?]+)")) - if (!urlMatch) { return } - const currentPath = urlMatch[1] - - const addCss = (cssCode) => { - const styleElement = document.createElement("style") - styleElement.type = "text/css" - document.getElementsByTagName("head")[0].appendChild(styleElement) - if (styleElement.styleSheet) { - styleElement.styleSheet.cssText = cssCode - } else { - styleElement.innerHTML = cssCode - } - } - - const addLink = (text, url) => { - const githubIconLink = document.querySelector(`div[data-testid="PipelineHeader"] a[href*="https://github.com/"] svg`).parentNode - const deploymentsLink = githubIconLink.cloneNode(true) - deploymentsLink.href = url - deploymentsLink.title = 'https://buildkite.com' + url - deploymentsLink.textContent = text - deploymentsLink.className += ' zimbix-alternate-pipeline-link' - githubIconLink.parentNode.insertBefore(deploymentsLink, githubIconLink) - } - - const checkIfUrlExists = async (url) => { - console.log(url) - const response = await fetch(url, { method: 'HEAD', credentials: 'include' }) - // return response.ok - return (response.ok && !response.redirected) - } - - const addLinkIfUrlExists = async (linkText, linkUrl) => { - if (linkUrl == currentPath) { return } - const urlExists = await checkIfUrlExists(linkUrl) - if (urlExists) { addLink(linkText, linkUrl) } - } - - const specialCases = { - //'dex-core': 'dex-deployments', - 'dex-core': 'dex-environments', - 'dex-core-upgrades': 'dex-environments', - 'dex-environments': 'dex-core', - - 'anm-api-environments': 'anm', - 'anm': 'anm-api-environments', - - 'staff-http-proxy': 'staff-http-proxy/builds/latest', - } - - const generateUrl = (find, replace) => { - const pipelineName = currentPath.replace(new RegExp('^/gs/'), '').toLowerCase() - const specialCase = specialCases[pipelineName] - return specialCase ? '/gs/' + specialCase : currentPath.replace(new RegExp(find), replace) - } - - addCss( - ".zimbix-alternate-pipeline-link {" + - " font-size: 1.4em;" + - " margin-left: 7px;" + - " padding-left: 8px;" + - " margin-right: -8px;" + - " padding-right: 8px;" + - " z-index: 1;" + - "}" + - ".zimbix-alternate-pipeline-link:hover {" + - " filter: brightness(1.2);" + - "}" - ) - - if (currentPath.match(new RegExp('-(environments|deployments)$'))) { - addLinkIfUrlExists('📦', generateUrl('-(environments|deployments)', '')) - } else { - new Set([ - generateUrl('$', '-environments'), - generateUrl('$', '-deployments'), - ]).forEach(url => addLinkIfUrlExists('🚀', url)) - } -})() diff --git a/github/make-toc-bigger.user.js b/github/make-toc-bigger.user.js deleted file mode 100644 index 4e07f6d..0000000 --- a/github/make-toc-bigger.user.js +++ /dev/null @@ -1,60 +0,0 @@ -// ==UserScript== -// @name GitHub: Make TOC popup bigger -// @namespace http://tampermonkey.net/ -// @version 1.0 -// @description Makes it much easier to navigate a large table of contents in a Markdown document -// @author Brendan Weibrecht -// @match https://github.com/* -// @icon https://github.githubassets.com/favicons/favicon.svg -// @grant none -// ==/UserScript== - -(function() { - 'use strict'; - - // http://youmightnotneedjquery.com/#delegate - const onEvent = (eventName, elementSelector, handler) => { - addEventListener(eventName, function(e) { - // loop parent nodes from the target to the delegation node - for (var target = e.target; target && target != this; target = target.parentNode) { - if (target.matches && target.matches(elementSelector)) { - handler.call(target, e); - break; - } - } - }, true); - }; - - const addCss = (cssCode) => { - const styleElement = document.createElement("style") - styleElement.type = "text/css" - document.getElementsByTagName("head")[0].appendChild(styleElement) - if (styleElement.styleSheet) { - styleElement.styleSheet.cssText = cssCode - } else { - styleElement.innerHTML = cssCode - } - } - - // Make the TOC just about as wide as the repo readme, and nicely fill the window height if it's longer than that - addCss("readme-toc .js-sticky .SelectMenu-modal { width: 878px; max-height: calc(100vh - 80px) !important; }") - - // Increase the indent of TOC menu items to aid visual differentiation of heading levels - document.querySelectorAll('readme-toc .js-sticky .SelectMenu-list a').forEach((item) => { - const paddingLeft = getComputedStyle(item).paddingLeft - item.style.paddingLeft = `calc(${paddingLeft} * 2)` - }) - - // On opening the TOC, scroll down to show the full TOC menu if necessary - onEvent('click', 'readme-toc .js-sticky details', (e) => { - const readme = document.querySelector('#readme') - const isTocBannerAtTopOfWindow = readme.getBoundingClientRect().top < 0 - if (!isTocBannerAtTopOfWindow) { - const readmeY = readme.getBoundingClientRect().top + window.scrollY - // Unlike the repo readme, on doc pages, the banner jumps out of position, so we need to compensate - const jumpingBanner = e.target.closest('.Box-header.js-sticky') - const jumpingBannerHeight = jumpingBanner ? jumpingBanner.getBoundingClientRect().height : 0 - window.scroll({ top: readmeY - jumpingBannerHeight + 1 }) - } - }) -})(); diff --git a/pop/auto-close-join-tab.user.js b/pop/auto-close-join-tab.user.js deleted file mode 100644 index 978fe6c..0000000 --- a/pop/auto-close-join-tab.user.js +++ /dev/null @@ -1,16 +0,0 @@ -// ==UserScript== -// @name Pop: Auto-close session join tab -// @namespace http://tampermonkey.net/ -// @version 0.1 -// @description try to take over the world! -// @author You -// @match https://pop.com/j/* -// @icon https://www.google.com/s2/favicons?sz=64&domain=pop.com -// @grant window.close -// ==/UserScript== - -(function() { - 'use strict'; - - setTimeout(() => { window.close(); }, 10000); -})(); diff --git a/zenhub/highlight-unchanged-repo.user.js b/zenhub/highlight-unchanged-repo.user.js deleted file mode 100644 index eeb4af0..0000000 --- a/zenhub/highlight-unchanged-repo.user.js +++ /dev/null @@ -1,54 +0,0 @@ -// ==UserScript== -// @name ZenHub: Highlight unchanged repo during issue creation -// @namespace http://tampermonkey.net/ -// @version 0.1 -// @description It's easy to forget to change the default repo when creating an issue on ZenHub; so make it easier to see that you haven't by showing a red border around the repo field until you click on it -// @author Brendan Weibrecht -// @match https://app.zenhub.com/workspaces/* -// @grant none -// @icon https://app.zenhub.com/dist/favicon/apple-touch-icon.png -// ==/UserScript== - -(function() { - 'use strict'; - - // http://youmightnotneedjquery.com/#delegate - const onEvent = (eventName, elementSelector, handler) => { - addEventListener(eventName, function(e) { - // loop parent nodes from the target to the delegation node - for (var target = e.target; target && target != this; target = target.parentNode) { - if (target.matches && target.matches(elementSelector)) { - handler.call(target, e); - break; - } - } - }, true); - }; - - const addCss = (cssCode) => { - const noopTrustPolicy = trustedTypes.createPolicy("noopTrustPolicy", { - createHTML: (string) => string - }) - const styleElement = document.createElement("style") - styleElement.type = "text/css" - document.getElementsByTagName("head")[0].appendChild(styleElement) - if (styleElement.styleSheet) { - styleElement.styleSheet.cssText = cssCode - } else { - styleElement.innerHTML = noopTrustPolicy.createHTML(cssCode) - } - } - - addCss(` - button[aria-label="Create Issue in Repo"]:not(.zimbix-changed) { - border: 2px solid red !important; - } - `) - - const handleRepoChange = (e) => { - const button = e.target.closest('button[aria-label="Create Issue in Repo"]') - button.classList.add('zimbix-changed'); - } - - onEvent('click', 'button[aria-label="Create Issue in Repo"]', handleRepoChange); -})(); diff --git a/zenhub/link-from-board-to-github-issue.user.js b/zenhub/link-from-board-to-github-issue.user.js deleted file mode 100644 index 246cbe7..0000000 --- a/zenhub/link-from-board-to-github-issue.user.js +++ /dev/null @@ -1,90 +0,0 @@ -// ==UserScript== -// @name ZenHub: Link from board to GitHub issues. For ZenHub Board 2.0 -// @namespace http://tampermonkey.net/ -// @version 0.2 -// @description When opening issues from a ZenHub board, use GitHub's UI rather than ZenHub's - when clicking on the issue title. Like a normal link, it supports both left-click (open in current tab) and middle-click (open in new tab). To open an issue in ZenHub's UI, click on any non-title part of the card. To drag an issue, you'll need to drag from any non-title part of the card. -// @author Brendan Weibrecht -// @match https://app.zenhub.com/workspaces/* -// @icon https://app.zenhub.com/dist/favicon/apple-touch-icon.png -// @grant none -// ==/UserScript== - -(function() { - 'use strict'; - - // http://youmightnotneedjquery.com/#delegate - const onEvent = (eventName, elementSelector, handler) => { - addEventListener(eventName, function(e) { - // loop parent nodes from the target to the delegation node - for (var target = e.target; target && target != this; target = target.parentNode) { - if (target.matches && target.matches(elementSelector)) { - handler.call(target, e); - break; - } - } - }, true); - }; - - const getIssueUrlForAddingLinkToCard = (cardTitleElement) => { - const headingElement = cardTitleElement.parentNode.children[0]; - if (!headingElement) { return }; - const [issueRepo, issueNumber] = Array(...headingElement.querySelectorAll('span > span[title]')).map(e => e.title.replace('#', '')); - return `https://github.com/greensync/${issueRepo}/issues/${issueNumber}`; - }; - - const getIssueLinkUrlFromCard = (cardTitleElement) => { - return cardTitleElement.closest('.github-link').href; - }; - - const navigateToIssuePageForCard = (cardTitleElement) => { window.open(getIssueLinkUrlFromCard(cardTitleElement), '_blank'); }; - - const wrap = (toWrap, wrapper) => { - wrapper = wrapper; - toWrap.parentNode.appendChild(wrapper); - return wrapper.appendChild(toWrap); - }; - - const stopEvent = (event) => { - console.log(event.type); - event.stopImmediatePropagation(); - event.stopPropagation(); - event.preventDefault(); - }; - - const addTitleLink = (cardTitleElement) => { - const link = document.createElement('a'); - link.className = 'github-link'; - link.href = getIssueUrlForAddingLinkToCard(cardTitleElement); - link.onmousedown = stopEvent; - link.onmouseup = stopEvent; - wrap(cardTitleElement, link); - }; - - const addTitleLinkIfNeeded = (cardTitleElement) => { - const existingLinkElement = cardTitleElement.parentNode.parentNode.querySelector('.github-link'); - existingLinkElement || addTitleLink(cardTitleElement); - }; - - const refreshGithubLinks = () => { - const cardIssueNumberElements = - Array(...document.querySelectorAll("div[data-testid='board-issue-card'] span[title^='#']")).filter(e => e.title.match(new RegExp('^#[0-9]+$'))); - const cardTitleElements = cardIssueNumberElements.map(e => e.parentElement.parentElement.parentElement.children[1]); - cardTitleElements.forEach(addTitleLinkIfNeeded); - setTimeout(refreshGithubLinks, 1000); - }; - - const eventIsPrimaryMouseClick = (event) => (event.type == 'click'); - - const handleMouseClickEvent = (event) => { - if (eventIsPrimaryMouseClick(event)) { - navigateToIssuePageForCard(event.target) - stopEvent(event); - }; - }; - - ['click', 'mousedown'].forEach((eventName) => { - onEvent(eventName, '.github-link', handleMouseClickEvent); - }) - - refreshGithubLinks(); -})(); diff --git a/zenhub/redirect-from-issue-to-github-issue.user.js b/zenhub/redirect-from-issue-to-github-issue.user.js deleted file mode 100644 index fba2d4d..0000000 --- a/zenhub/redirect-from-issue-to-github-issue.user.js +++ /dev/null @@ -1,29 +0,0 @@ -// ==UserScript== -// @name ZenHub: Redirect from issue to GitHub issue -// @namespace http://tampermonkey.net/ -// @version 0.2 -// @description Redirect from Zenhub issue to GitHub issue -// @author Brendan Weibrecht -// @match https://app.zenhub.com/workspaces/*/issues/* -// @grant none -// @run-at document-start -// @icon https://app.zenhub.com/dist/favicon/apple-touch-icon.png -// ==/UserScript== - -(function() { - 'use strict'; - -// const redirect = () => { -// const link = document.querySelector('.zhc-view-issue-link') -// if (link) { -// window.location = link.href -// } else { -// setTimeout(redirect, 10) -// } -// } -// -// redirect() - - const matches = window.location.href.match(new RegExp(".*/issues/gh/(?[^/]+)/(?[^/]+)/(?[0-9]+)")).groups - window.location = `https://github.com/${matches.org}/${matches.repo}/issues/${matches.issue}` -})();