blob: e324bb2f985d36826abff96d3f9ec56bf34846a1 (
plain)
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
61
62
63
64
65
66
67
68
69
70
|
/**
* ==VimperatorPlugin==
* @name inspector
* @description DOM Inspector commands
* @depend "DOM Inspector" inspector@mozilla.org
* @version 1.0
* ==/VimperatorPlugin==
*/
(function(){
const inspectorID = 'inspector@mozilla.org';
if (!Application.extensions.get(inspectorID).enabled) return;
/* これやるとFirefox終了時に実行されるんだけど...なぜ?
Object.prototype.inspect = function(){
runInspector(this);
}
*/
function runInspector(node){
if (node instanceof Document){
inspectDOMDocument(node);
} else if (node instanceof Node){
inspectDOMNode(node);
} else if (node !== null && typeof(node) != "undefined"){
inspectObject(node);
}
}
function getFrameList(){
var list = [];
var iframeList = document.getElementsByTagName("iframe");
for (var i=0, max=iframeList.length ; i<max ; ++i){
if (iframeList[i].hasAttribute("id"))
list.push([iframeList[i].id,'iframe id']);
}
return list;
}
commands.addUserCommand(['inspect','dominspect'],'run DOM Inspector',
function(arg, bang){
if (!arg.string){
bang ? inspectDOMDocument(document) : inspectDOMDocument(content.document);
return;
}
var list = getFrameList();
var index = list.map(function($_) $_[0]).indexOf(arg.string);
var node;
if (index != -1) node = document.getElementById(list[index][0]).contentDocument;
if (!node){
try {
node = window.eval("with(liberator){" + arg.string + "}");
} catch(e) {
liberator.echoerr(e);
return;
}
}
runInspector(node);
},{
bang: true,
completer: function(filter){
var list = completion.filter(getFrameList(), filter, true);
if (list.length > 0) return [0, list];
return completion.javascript(filter);
},
}
);
})();
|