From ad28c4dba448beff9d80ff21f80733018a8a7fda Mon Sep 17 00:00:00 2001 From: Bas Weelinck Date: Tue, 20 Nov 2018 16:50:52 +0100 Subject: [PATCH] garland: Add location fixer user script. --- garland/garland-location-fixer.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 garland/garland-location-fixer.js diff --git a/garland/garland-location-fixer.js b/garland/garland-location-fixer.js new file mode 100644 index 0000000..c79db9f --- /dev/null +++ b/garland/garland-location-fixer.js @@ -0,0 +1,30 @@ +// ==UserScript== +// @name Garland location fixer +// @version 1 +// @include http://www.garlandtools.org/db/* +// @run-at document-end +// @grant none +// ==/UserScript== + +/* Patch gathering material resolver */ +function garlandLocationFixer() { + 'use strict'; + console.log('fixer: garlandLocationFixer, v1.0'); + console.log('fixer: installing monkey patch'); + let actual_resolve = gt.node.resolveCraftSource; + gt.node.resolveCraftSource = function(step, id) { + actual_resolve(step, id); + let view = step.sourceView; + console.log('fixer: Adding ' + view.name + ' to ' + view.longSourceName); + view.longSourceName = view.name + ', ' + view.longSourceName; + console.log('fixer: done.'); + } + console.log('fixer: done.'); +} + +/* Add script to execute in page scope */ +var script = document.createElement("script"); +script.type = "application/javascript"; +script.textContent = "(" + garlandLocationFixer + ")();"; + +document.body.appendChild(script);