Skip to content

Instantly share code, notes, and snippets.

@FredrikWendt

FredrikWendt/test.js

Created Nov 11, 2014
Embed
What would you like to do?
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
You can’t perform that action at this time.