Skip to content

Instantly share code, notes, and snippets.

@KingBain
Last active May 3, 2023 17:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KingBain/a7d542747952a3b92837748809b4d3aa to your computer and use it in GitHub Desktop.
Save KingBain/a7d542747952a3b92837748809b4d3aa to your computer and use it in GitHub Desktop.
Veggie Agile
// ==UserScript==
// @name Veggie Agile
// @author John Bain
// @version 0.1
// @description Change all GitHub words for agile to veggies
// @match *://github.com/*project*
// @icon https://raw.githubusercontent.com/xthexder/wide-github/master/icons/icon.png
// @updateURL https://gist.githubusercontent.com/KingBain/a7d542747952a3b92837748809b4d3aa/raw/Veggie_Agile.js
// @downloadURL https://gist.githubusercontent.com/KingBain/a7d542747952a3b92837748809b4d3aa/raw/Veggie_Agile.js
// @grant none
// ==/UserScript==
(function() {
'use strict';
var replaceArry = [
[/\bSprint\b/gi, 'Lettuce'],
[/\bSprints\b/gi, 'Lettuces'],
[/\bBacklog\b/gi, 'Spinach'],
[/\bEpic\b/gi, 'Arugula'],
[/\bEpics\b/gi, 'Arugulas'],
[/\bUser Story\b/gi, 'Kale Leaf'],
[/\bScrum Master\b/gi, 'Radish Stalk'],
[/\bProduct Owner\b/gi, 'Carrot Top'],
[/\bRetrospective\b/gi, 'Cucumber'],
[/\bBurndown Chart\b/gi, 'Green Pepper Graph'],
[/\bProject\b/gi, 'Cabbage'],
[/\bProjects\b/gi, 'Cabbages'],
[/\bUser stories\b/gi, 'Kale Leaves'],
[/\bTask\b/gi, 'Broccoli'],
[/\bTasks\b/gi, 'Broccolis'],
[/\bFeature\b/gi, 'Bell Pepper'],
[/\bFeatures\b/gi, 'Bell Peppers'],
[/\bFeat\b/gi, 'Bell'],
[/\bFeats\b/gi, 'Bells'],
[/\bDeliverable\b/gi, 'Tomato'],
[/\bDeliverables\b/gi, 'Tomatoes'],
[/\bTouchstone\b/gi, 'Celery'],
[/\bTouchstones\b/gi, 'Celeries'],
[/\bTSK\b/gi, 'Broccoli'],
[/\bUS\b/gi, 'Kale Leaf'],
[/\bEPIC\b/gi, 'Arugula'],
[/\bFEAT\b/gi, 'Bell'],
[/\bPO\b/gi, 'Carrot Top'],
[/\bPM\b/gi, 'Radish Stalk'],
];
var numTerms = replaceArry.length;
function replaceTextNodes(node) {
var walker = document.createTreeWalker(
node,
NodeFilter.SHOW_TEXT,
null,
false
);
while (walker.nextNode()) {
var oldTxt = walker.currentNode.nodeValue;
for (var J = 0; J < numTerms; J++) {
var re = replaceArry[J][0];
var replacement = replaceArry[J][1];
oldTxt = oldTxt.replace(re, replacement);
}
walker.currentNode.nodeValue = oldTxt;
}
}
// Replace text on initial page load
replaceTextNodes(document.body);
// Watch for changes to the page and replace text nodes
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
var node = mutation.target;
if (node.nodeType === Node.TEXT_NODE) {
replaceTextNodes(node.parentNode);
} else {
replaceTextNodes(node);
}
});
});
observer.observe(document.body, {
childList: true,
subtree: true
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment