// ==UserScript==
// @name Simplepedia
// @namespace https://simple.wikipedia.org/
// @version 0.1
// @description Redirects English Wikipedia to Simple Wikipedia automatically, making everything easier to understand.
// @author KodeItDEV
// @copyright 2018, KodeItDEV (https://openuserjs.org/users/KodeItDEV)
// @license MIT
// @match en.wikipedia.org/wiki/*
// @match simple.wikipedia.org/wiki/*
// @exclude /en\.wikipedia\.org/wiki/Main_Page/
// @exclude /en\.wikipedia\.org/wiki/Portal:.*$/
// @grant GM_xmlhttpRequest
// @grant GM_setValue
// @grant GM_getValue
// @grant unsafeWindow
// @run-at document-start
// ==/UserScript==
function getURL() {
var url = window.location.protocol + "//" + window.location.host + window.location.pathname;
return url;
}
if (GM_getValue('simpped')) {
if (window.location.host !== 'simple.wikipedia.org') {
(function() {
var url = getURL();
url = url.replace(/en/, 'simple');
window.location.replace(url);
})();
} else {
(function search() {
var isArticle = document.getElementsByClassName('noarticletext mw-content-ltr');
if (isArticle.length > 0) {
if (confirm('This article does not exist! Go back to Wikipedia?')) {
GM_setValue('simpped', false);
var url = getURL();
url = url.replace(/simple/, 'en');
window.location.replace(url);
}
}
})();
}
} else {
GM_setValue('simpped', true);
}