Last active
August 29, 2015 14:26
-
-
Save Locke/a36be9209eb2f641f091 to your computer and use it in GitHub Desktop.
osmhv.user.js
This file contains 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 OSM History Viewer link | |
// @namespace osmhv.openstreetmap.de | |
// @description Adds links to OSM History Viewer on OpenStreetMap relation and changeset pages. Fork of http://userscripts-mirror.org/scripts/review/92776 | |
// @include http://www.openstreetmap.org/* | |
// @include https://www.openstreetmap.org/* | |
// @version 1.2 | |
// @grant none | |
// ==/UserScript== | |
var trans = { | |
"relation" : "Blame in OSM History Viewer", | |
"changeset" : "View in OSM History Viewer" | |
}; | |
var m = location.pathname.match(/^\/(changeset|relation)\/(\d+)/); | |
if (m) { | |
var type = m[1]; | |
var id = m[2]; | |
var headline = document.createElement("h2"); | |
var hvLink = document.createElement("a"); | |
hvLink.href = "http://osmhv.openstreetmap.de/" + (type == "relation" ? "blame" : "changeset") + ".jsp?id=" + encodeURIComponent(id); | |
hvLink.target = "_blank"; | |
hvLink.appendChild(document.createTextNode(trans[type])); | |
headline.appendChild(hvLink); | |
var sidebar = document.getElementById("sidebar_content"); | |
sidebar.insertBefore(headline, sidebar.firstChild); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment