Skip to content

Instantly share code, notes, and snippets.

@thevladeffect
Last active November 19, 2019 07:41
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 thevladeffect/f6b60d20428c00d1a9dfdbada91aa478 to your computer and use it in GitHub Desktop.
Save thevladeffect/f6b60d20428c00d1a9dfdbada91aa478 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Board Games Hub
// @namespace https://github.com/thevladeffect
// @version 0.2
// @description Add Board Games Hub link to game page
// @author Vlad
// @match boardgamegeek.com/boardgame*
// @grant none
// ==/UserScript==
(function() {
'use strict';
function getElementByXpath(path) {
return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
}
const title = getElementByXpath("(//a[@ui-sref='geekitem.overview'])[2]").text.trim();
const url = `http://www.boardgameshub.ro/stock/${encodeURI(title)}`;
const link = document.createElement('a');
link.className = 'btn-group-sm';
link.href = url;
link.target = '_blank';
const button = document.createElement('button');
button.className = 'btn btn-subtle';
button.textContent = 'Board Games Hub';
link.append(button);
const actions = document.getElementsByClassName('toolbar-actions')[0];
actions.appendChild(link);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment