Created
November 11, 2014 23:58
-
-
Save FredrikWendt/42bbbd2b283525b951f7 to your computer and use it in GitHub Desktop.
ScrumGuides Greasemonkey script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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