Created
November 11, 2014 23:58
Revisions
-
FredrikWendt created this gist
Nov 11, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,45 @@ // ==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();