Created
December 13, 2019 08:15
-
-
Save msoxzw/bfd3fac70ab615e13958d14e440062ce to your computer and use it in GitHub Desktop.
Internet Explorer Tracking Protection Lists dynamically generated by Adblock Plus subscriptions with multiple languages choices given by wikimeida
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
<!DOCTYPE html> | |
<!-- saved from url=(0014)about:internet --> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Internet Explorer Tracking Protection Lists</title> | |
<style> | |
body { | |
font-family: Segoe UI, sans-serif, Segoe UI Emoji; | |
} | |
h1 { | |
padding-left: 20px; | |
font-size: 24pt; | |
font-weight: normal; | |
color: #00a3ef; | |
} | |
p { | |
padding-left: 20px; | |
} | |
a { | |
color: #00a3ef; | |
text-decoration: none; | |
} | |
a:hover { | |
text-decoration: underline; | |
} | |
.subscription { | |
float: left; | |
width: 200px; | |
height: 150px; | |
margin: 20px; | |
background-color: #00a3ef; | |
} | |
.subscription a { | |
display: block; | |
color: white; | |
font-size: 20px; | |
position: relative; | |
left: 20px; | |
top: 30px; | |
margin-right: 20px; | |
} | |
</style> | |
</head> | |
<body> | |
<h1>Tracking Protection Lists</h1> | |
<label style="float: right">🌐<select id="language"></select></label> | |
<p><a href="https://adblockplus.org/subscriptions" rel="noopener noreferrer" target="_blank">From known Adblock Plus subscriptions</a></p> | |
<script> | |
function getJSON(url, callback) { | |
var request = new XMLHttpRequest(); | |
request.onload = function () { | |
callback(JSON.parse(this.response)) | |
}; | |
request.open('GET', url); | |
request.send(); | |
} | |
var autonymURL = "https://www.mediawiki.org/w/api.php?action=query&meta=languageinfo&liprop=autonym&format=json&origin=*"; | |
var subscriptionsURL = "https://raw.githubusercontent.com/adblockplus/adblockpluscore/master/data/subscriptions.json"; | |
getJSON(autonymURL, function (languageinfo) { | |
var autonym = languageinfo.query.languageinfo; | |
var select = document.getElementById("language"); | |
for (var code in autonym) { | |
if (autonym.hasOwnProperty(code)) { | |
var name = autonym[code].autonym; | |
if (name) { | |
var option = document.createElement("option"); | |
option.value = code; | |
option.lang = code; | |
option.textContent = name; | |
select.appendChild(option); | |
} | |
} | |
} | |
select.selectedIndex = -1; | |
getJSON(subscriptionsURL, function (subscriptions) { | |
for (var i = 0; i < subscriptions.length; i++) { | |
var languages = subscriptions[i].languages; | |
var title = subscriptions[i].title; | |
var url = subscriptions[i].url; | |
var subscription = document.createElement("div"); | |
subscription.className = "subscription"; | |
var link = document.createElement("a"); | |
link.href = "javascript:window.external.msAddTrackingProtectionList('" + url.replace(/\.txt$/, ".tpl") + "', '" + title + "')"; | |
link.textContent = "Add the " + title.replace(/\+/g, " + "); | |
if (languages) { | |
var spans = languages.map(function (lang) { | |
var span = document.createElement("span"); | |
span.className = lang; | |
span.lang = lang; | |
span.textContent = autonym[lang].autonym; | |
return span.outerHTML; | |
}); | |
link.innerHTML += " (" + spans.join(", ") + ")"; | |
} | |
subscription.appendChild(link); | |
document.body.appendChild(subscription); | |
} | |
}); | |
}); | |
document.getElementById("language").addEventListener("change", function () { | |
var lang = this.value; | |
var namesURL = "https://www.mediawiki.org/w/api.php?action=query&meta=languageinfo&liprop=name&uselang=" + lang + "&format=json&origin=*"; | |
getJSON(namesURL, function (languageinfo) { | |
var names = languageinfo.query.languageinfo; | |
var spans = document.querySelectorAll(".subscription span"); | |
for (var i = 0; i < spans.length; i++) { | |
spans[i].lang = lang; | |
spans[i].textContent = names[spans[i].className].name; | |
} | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment