Last active
November 1, 2018 12:40
-
-
Save maxerickson/f729e5ded1f0aff1dbe983129b26471c to your computer and use it in GitHub Desktop.
Ease copying OSM tags for Wikipedia entry.
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 Wiki tags | |
// @namespace maxerickson | |
// @version 0.1 | |
// @description Add osm style key=value tags to wikipedia pages. | |
// @author Max Erickson | |
// @match *://*.wikipedia.org/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var wikipedia=document.getElementById("firstHeading").textContent; | |
var wikidata=document.getElementById("t-wikibase").firstChild.href; | |
var re = /https?:\/\/www.wikidata.org\/wiki\/Special:EntityPage\/(.*)|/; | |
var wd2=re.exec(wikidata)[1]; | |
var tags=document.createElement("span"); | |
var prefix=document.location.hostname.slice(0,2); | |
var fill=""; | |
tags.style.position="absolute"; | |
tags.style.top="10px"; | |
tags.style.left="30%"; | |
tags.style.padding="10px"; | |
tags.style.backgroundColor="white"; | |
tags.style.outline="black solid"; | |
fill="wikipedia="+prefix+":"+wikipedia+"<br/>wikidata="+wd2; | |
fill=fill+'<br/> "brand:wikidata": "'+wd2; | |
fill=fill+'",<br/> "brand:wikipedia": "'+prefix+':'+wikipedia+'",'; | |
tags.innerHTML=fill; | |
document.body.append(tags); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment