2020-07-31 22:57:32 +02:00
|
|
|
// document.body.style.border = "15px solid red";
|
|
|
|
|
2020-07-31 23:19:43 +02:00
|
|
|
/*
|
|
|
|
TODO
|
|
|
|
- Pop-up should be formatted to look better.
|
|
|
|
- Pop-up should be dismissable (per URL / per domain).
|
|
|
|
- Once dismissed, popup should not be shown on the same url/domain. Use cookies or localStorage for this.
|
|
|
|
- List of alternatives should be loaded from a user-specified external source. Can be modified via options.html/options.js
|
|
|
|
- Since we're replacing innerHTML, we should protect against XSS attacks.
|
2020-07-31 22:57:32 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
BETTER_ALTERNATIVES = [
|
|
|
|
[ /https?:\/\/(www.)?google.com\/chrome/ , "A better alternative is <a href='https://mozilla.com' target='_blank'>Mozilla</a>."]
|
|
|
|
]
|
|
|
|
|
|
|
|
function findBetter(url) {
|
|
|
|
var match = BETTER_ALTERNATIVES.find(pattern => url.match(pattern[0]));
|
|
|
|
if(match)
|
|
|
|
return match[1];
|
|
|
|
else return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
function showBetter(alternative) {
|
|
|
|
if(!alternative) return;
|
|
|
|
let betterdiv = document.createElement("div");
|
|
|
|
betterdiv.style.backgroundColor = "yellow";
|
|
|
|
betterdiv.style.color = "red";
|
|
|
|
betterdiv.style.position = "fixed";
|
|
|
|
betterdiv.style.bottom = "10px";
|
|
|
|
betterdiv.style.right = "10px";
|
|
|
|
betterdiv.style.width = "400px";
|
|
|
|
betterdiv.style.height = "200px";
|
|
|
|
betterdiv.style.textAlign = "center";
|
|
|
|
betterdiv.style.fontSize = "20px";
|
|
|
|
betterdiv.innerHTML = alternative;
|
|
|
|
document.body.appendChild(betterdiv);
|
|
|
|
}
|
|
|
|
|
|
|
|
showBetter(findBetter(document.location.href));
|