Gebruiker:Smile4ever/GetArchive4Wikipedia.js
Uiterlijk
Opmerking: nadat u de wijzigingen hebt gepubliceerd is het wellicht nodig uw browsercache te legen.
- Firefox / Safari: houd Shift ingedrukt terwijl u op Vernieuwen klikt of druk op Ctrl-F5 of Ctrl-R (⌘-Shift-R op een Mac)
- Google Chrome: druk op Ctrl-Shift-R (⌘-Shift-R op een Mac)
- Internet Explorer / Edge: houd Ctrl ingedrukt terwijl u op Vernieuwen klikt of druk op Ctrl-F5
- Opera: druk op Ctrl-F5.
/* Simpel script om bepaalde links toe te voegen
https://nl.wikipedia.org/wiki/Gebruiker:Smile4ever/GetArchive4Wikipedia.js
*/
function main(){
let externalLinks = document.querySelectorAll(".external");
let isSpecialPage = window.location.href.indexOf("%3A") > -1 && window.location.href.indexOf("&") > -1;
let isChecklistPDF = window.location.href.includes("ChecklistPDF");
if(isSpecialPage || isChecklistPDF) return;
for(let i = 0; i < externalLinks.length; i++){
let externalLink = externalLinks[i];
externalLink.setAttribute("color", "red");
let container = externalLink.parentElement;
let externalLinkLocation = externalLink.getAttribute("href");
if(externalLinkLocation.indexOf("wikipedia.org") > -1) continue;
if(externalLinkLocation.indexOf("//") == 0){
externalLinkLocation = "https:" + externalLinkLocation;
}
// archive.org
if(externalLinkLocation.indexOf("archive.") == -1){
let linkToArchiveOrg = "https://web.archive.org/web/2005/" + externalLinkLocation;
let aTag = document.createElement('a');
aTag.setAttribute('href', linkToArchiveOrg);
aTag.setAttribute('target', "blank");
aTag.setAttribute('title', "Go to archive.org");
aTag.innerHTML = "[archive.org]";
aTag.setAttribute("style", "margin-left: 0.3em; font-size: 0.8em; font-style: normal");
container.appendChild(aTag);
}
// archive.is
if(externalLinkLocation.indexOf("archive.") == -1){
let linkToArchiveIs = "https://archive.is/" + externalLinkLocation;
let aTag2 = document.createElement('a');
aTag2.setAttribute('href', linkToArchiveIs);
aTag2.setAttribute('target', "blank");
aTag2.setAttribute('title', "Go to archive.is");
aTag2.innerHTML = "[archive.is]";
aTag2.setAttribute("style", "margin-left: 0.3em; font-size: 0.8em; font-style: normal");
container.appendChild(aTag2);
}
// manage URL single
let realLocation = externalLinkLocation;
if(externalLinkLocation.lastIndexOf("https://") > 10){
realLocation = externalLinkLocation.substring(externalLinkLocation.lastIndexOf("https://"));
}
if(externalLinkLocation.lastIndexOf("http://") > 10){
realLocation = externalLinkLocation.substring(externalLinkLocation.lastIndexOf("http://"));
}
if(realLocation != ""){
let linkToManageUrlSingle = "https://tools.wmflabs.org/iabot/index.php?page=manageurlsingle&url=" + realLocation;
let aTag3 = document.createElement('a');
aTag3.setAttribute('href', linkToManageUrlSingle);
aTag3.setAttribute('target', "blank");
aTag3.setAttribute('title', "Go to InternetArchiveBot's URL management page");
aTag3.innerHTML = "[manage URL]";
aTag3.setAttribute("style", "margin-left: 0.3em; font-size: 0.8em; font-style: normal");
container.appendChild(aTag3);
}
}
}
if(window.location.href.indexOf("Overleg") == -1 || document.querySelector("#mw-content-text").innerText.includes("Externe link")){
main();
}