-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
56 lines (47 loc) · 2.16 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
var pageMod = require("sdk/page-mod");
var data = require("sdk/self").data;
var preferences = require("sdk/preferences/service");
var simple_prefs = require("sdk/simple-prefs");
DEFAULT_DOMAINS = "al;am;ba;be;bg;ca;ch;co.id;co.uk;co.za;com.ar;com.au;com.br;com.by;com.co;com.cy;com.ee;com.eg;com.es;com.mt;com.ng;com.tr;com.uy;de;fr;gr;hr;ie;in;is;it;li;lt;lu;md;mk;mx;my;nl;no;pe;pt;qa;ro;rs;se;sg;si;sn;ug";
AC_DOMAINS = "[email protected]";
REDIRECT_BLOGGER = "[email protected]_blogger";
REDIRECT_GOOGLE = "[email protected]_google";
function onDomainsUpdated() {
var redirected_domains = generateDomainLists();
registerRedirectFunction(redirected_domains);
}
function generateDomainLists() {
var domains = preferences.get(AC_DOMAINS, DEFAULT_DOMAINS).split(";");
var redirected_domains = [];
for (var i = 0; i < domains.length; i++) {
redirected_domains.push("*.blogspot." + domains[i]);
}
return redirected_domains;
}
function setAboutConfig(key, value) {
// Set default about:config value if it doesn't exist
if (!preferences.has(key)) {
preferences.set(key, value);
}
}
function registerRedirectFunction(redirected_domains) {
if (typeof pm !== 'undefined') {
pm.destroy();
}
pm = pageMod.PageMod({
contentScriptWhen: 'start',
include: redirected_domains,
contentScriptFile: data.url("redirect_script.js")
});
}
exports.main = function() {
setAboutConfig(AC_DOMAINS, DEFAULT_DOMAINS); // Create settings in about config and configure listener in case settings are changed.
setAboutConfig(REDIRECT_BLOGGER, true); // If we allow to unredirect Google in the future, we may need to disable blogger unredirection.
setAboutConfig(REDIRECT_GOOGLE, false); // For current users, we disable Google unredirection for the future.
simple_prefs.on("domains", onDomainsUpdated);
var redirected_domains = generateDomainLists(); // Generate the list of domains to redirect.
registerRedirectFunction(redirected_domains); // Register the redirect function.
};
exports.onUnload = function() {
simple_prefs.removeListener("domains", onDomainsUpdated);
};