Skip to content

Instantly share code, notes, and snippets.

@ReallyLiri
Last active February 15, 2024 11:35
Show Gist options
  • Save ReallyLiri/da16a266f2782a39ab1b86c53f8a471c to your computer and use it in GitHub Desktop.
Save ReallyLiri/da16a266f2782a39ab1b86c53f8a471c to your computer and use it in GitHub Desktop.
Tampermonkey scripts
// ==UserScript==
// @name github-ignore-whitespace
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Github always ignore whitespace when reviewing a PR
// @author You
// @include https://github.com/*
// @icon https://www.google.com/s2/favicons?domain=undefined.localhost
// @grant GM_addStyle
// ==/UserScript==
const set = () => {
const href = window.location.href
console.log("checking page...", href)
if (href.endsWith("/files")) {
console.info("pull request is not ignoring whitespace -- redirecting")
window.location.replace(`${href}?w=1`)
}
for (const annotation of document.getElementsByClassName('check-annotation')) {
annotation.style.display = "none"
}
}
set()
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;
set()
}
});
var config = { childList: true, subtree: true };
observer.observe(bodyList, config);
};
// ==UserScript==
// @name Jira-Disable-Inline
// @namespace http://tampermonkey.net/
// @version 0.1
// @description disable jira issue click-to-edit (only applies few moments after page load, so you can have some grace time if you actually wanna edit)
// @author You
// @match https://*.atlassian.net/browse/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// ==/UserScript==
window.addEventListener('load', function () {
var element = document.querySelector('[data-testid="issue.views.field.rich-text.description"]');
if (element) {
console.debug("Disabling click on description")
element.addEventListener("click", e => {
if (e.metaKey || e.ctrlKey) {
return;
}
e.stopPropagation();
e.preventDefault();
}, true);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment