Skip to content

Instantly share code, notes, and snippets.

@FredrikWendt
Created November 11, 2014 23:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FredrikWendt/42bbbd2b283525b951f7 to your computer and use it in GitHub Desktop.
Save FredrikWendt/42bbbd2b283525b951f7 to your computer and use it in GitHub Desktop.
ScrumGuides Greasemonkey script
// ==UserScript==
// @name Adapt ScrumGuides
// @namespace se.wendt.scrumguides
// @include http://scrumguides.org/*
// @version 1
// @grant none
// ==/UserScript==
var a = function () {
var getURLParam = function(name) {
var search = window.location.search;
var pairs = search.substr(1).split("&");
for (var i = 0; i < pairs.length; i++) {
var parts = pairs[i].split("=");
if (parts[0] === name) {
return parseInt(parts[1], 10);
}
}
};
// expects something like .../scrum-guide.html?offset=3&limit=6#events-sprint
var nameOfReferenceElement = document.location.hash.substr(1);
var nodesToHighlight = getURLParam('limit');
var numberOfNodesToSkip = getURLParam('offset');
var highlightFrom = function (node) {
var nodesSkipped = 0;
for (var i = 0; i < numberOfNodesToSkip; i++) {
node = node.nextSibling;
}
for (i = 0; i < nodesToHighlight; i++) {
node.style = 'background: yellow';
node = node.nextSibling;
}
}
var startElement = document.getElementsByName(nameOfReferenceElement);
var anchors = document.getElementsByTagName('a');
for (var i = 0; i < anchors.length; i++) {
var anchor = anchors[i];
if (anchor.name === nameOfReferenceElement) {
return highlightFrom(anchor.parentNode);
}
}
};
a();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment