-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathatk-tools.js
45 lines (39 loc) · 1.13 KB
/
atk-tools.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
/**
* Get jQuery object properties of an element.
*
* @returns {{__proto__: null}}
*/
var page_getProperties = function() {
var data = window.jQuery && $0 ? jQuery.data($0) : {};
// Make a shallow copy with a null prototype, so that sidebar does not
// expose prototype.
var props = Object.getOwnPropertyNames(data);
var copy = { __proto__: null };
for (var i = 0; i < props.length; ++i)
copy[props[i]] = data[props[i]];
return copy;
};
/**
* Create Side panel
*/
chrome.devtools.panels.elements.createSidebarPane(
"Atk plugin Properties",
function(sidebar) {
function updateElementProperties() {
sidebar.setExpression("(" + page_getProperties.toString() + ")()");
}
updateElementProperties();
//add an select event listener to the element dev panel.
//when selection changed, will get new jQuery object properties and display it in side panel.
chrome.devtools.panels.elements.onSelectionChanged.addListener(
updateElementProperties);
});
/**
* Create a new panel in developper tool window.
*/
chrome.devtools.panels.create("ATK",
null,
"atk-panel.html",
function(panel){
}
);