-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathuserchrome.js
60 lines (52 loc) · 1.5 KB
/
userchrome.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
57
58
59
60
(function(){
dactyl.assert(typeof(userChrome_js) != 'undefined', "userChrome.js must exist");
var userChromeJS = {
list: function(all){
if(all){
return userChrome_js.scripts.concat(userChrome_js.overlays);
}else{
return userChrome_js.scripts;
}
},
get: function(name){
if(!name) return;
let scripts = [s for each(s in userChromeJS.list(true)) if(s.filename == name)];
if(scripts.length > 0)
return scripts[0];
else
return null;
},
completer: function(context, args, all){
context.title = ["script", "description"];
context.completions = [[s.filename, s.description] for each(s in userChromeJS.list(all))];
}
};
group.commands.add(['uce[dit]'], 'Edit an userChrome script',
function(args){
let s = userChromeJS.get(args[0]);
if(!s) return;
s.file.launch();
},
{
literal: 1,
completer: function(context, args){
userChromeJS.completer(context, args, true);
}
},
true
);
group.commands.add(['ucr[ehash]'], 'Reload an userChrome script',
function(args){
let s = userChromeJS.get(args[0]);
if(!s) return;
// services.observer.notifyObservers(s.file, "flush-cache-entry", "");
util.flushCache();
Services.scriptloader.loadSubScript(s.url, {}, s.charset || "utf-8");
},
{
literal: 1,
completer: userChromeJS.completer
},
true
);
})();