User:KrzysztofWecel/global.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
// ==UserScript==
// @name GFS Factual Consensus Finder Link for Wikimedia Pages
// @description GFS Factual Consensus Finder Link for Wikimedia Pages
// @author modified by Johannes Frey from oringinal DBpedia script by Anja Jentzsch
// @namespace none
// @include http://*.wikipedia.org/wiki/*
// ==/UserScript==
var allHTMLTags = new Array();
function getElementByClass(theClass) {
var allHTMLTags=document.getElementsByTagName('li');
for (i=0; i<allHTMLTags.length; i++) {
if (allHTMLTags[i].className == theClass) {
var link = allHTMLTags[i].firstChild.getAttribute("href");
if(link.search('en.wikipedia.org') > -1) {
return link;
}
}
}
return "";
}
var gfs_fcs = location.href.replace(/https?:\/\/www.wikidata.org\/wiki/,"http://www.wikidata.org/entity");
gfs_fcs = "https://global.dbpedia.org/?s=" + encodeURIComponent(decodeURIComponent(gfs_fcs));
addIconNextToTitle(gfs_fcs,"https://upload.wikimedia.org/wikipedia/commons/a/ae/73424-sync-symbol.svg","Show GFS Factual Consensus Finder");
var ref_extractor = "http://dbpedia.informatik.uni-leipzig.de:8111/infobox/references?article="+encodeURIComponent(decodeURIComponent(location.href))+"&format=json&dbpedia";
addIconNextToTitle(ref_extractor,"https://de.wikibooks.org/favicon.ico","Referenced Facts Extraction Microservice");
function addIconNextToTitle(url,img_url,hover_text) {
{
var firstHeading, dbpediaLink, pageTitle, hostName;
pageTitle = location.pathname.replace(/\/wiki/, "");
if (pageTitle.length > 0) {
firstHeading = document.getElementById('firstHeading');
dbpediaLink = document.createElement("a");
dbpediaLink.setAttribute("style","margin-left: 20px;");
dbpediaLink.setAttribute("href",url);
dbpediaImage = document.createElement("img");
dbpediaImage.setAttribute("style","border:none; height:1em;");
dbpediaImage.setAttribute("title",hover_text+" for " + firstHeading.firstChild.nodeValue);
dbpediaImage.setAttribute("src",img_url);
dbpediaLink.appendChild(dbpediaImage);
firstHeading.appendChild(dbpediaLink);
}
}
/*
} else {
var englishLink = getElementByClass('interwiki-en');
var link = "";
if(englishLink.search('en.wikipedia.org') > -1) {
link = englishLink;
} else {
link = getElementByClass('interwiki-en GA');
}
if(link.search('en.wikipedia.org') > -1) {
if (pageTitle.length > 0) {
firstHeading = document.getElementById('firstHeading');
dbpediaLink = document.createElement("a");
dbpediaLink.setAttribute("style","font-weight:bold; margin-left: 20px; margin-right: 20px;");
dbpediaLink.setAttribute("href","http://www.dbpedia.org/resource" + link.replace(/http:\/\/en.wikipedia.org\/wiki/, ""));
dbpediaImage = document.createElement("img");
dbpediaImage.setAttribute("style","border:none;");
dbpediaImage.setAttribute("title","DBpedia page for " + firstHeading.firstChild.nodeValue);
dbpediaImage.setAttribute("src","http://www4.wiwiss.fu-berlin.de/dbpedia/userscript/dbpedia.png");
dbpediaLink.appendChild(dbpediaImage);
firstHeading.appendChild(dbpediaLink);
}
} */
}