-
Notifications
You must be signed in to change notification settings - Fork 11
/
extDevToolsMouseGesturesLauncher.js
101 lines (88 loc) · 2.81 KB
/
extDevToolsMouseGesturesLauncher.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// http://infocatcher.ucoz.net/js/cb/extDevToolsMouseGesturesLauncher.js
// https://github.com/Infocatcher/Custom_Buttons/tree/master/Extensions_Developer_Tools
// Mouse Gestures Launcher for Extensions Developer Tools
// Also the code can be used from hotkeys (using keyconfig or similar extension)
// Copy all code from
// https://github.com/Infocatcher/Custom_Buttons/blob/master/Extensions_Developer_Tools/extDevTools.js
// after "//=== Extensions Developer Tools begin"
// (c) Infocatcher 2012-2024
// version 0.1.2 - 2024-03-06
(function() {
const popupsetId = "mgLauncherForExtDevTools-popupset";
var ps = document.getElementById(popupsetId);
ps && ps.parentNode.removeChild(ps);
ps = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "popupset");
ps.id = popupsetId;
document.documentElement.appendChild(ps);
function LOG(s) {
Components.classes["@mozilla.org/consoleservice;1"]
.getService(Components.interfaces.nsIConsoleService)
.logStringMessage("Mouse Gestures Launcher for Extensions Developer Tools:\n" + s);
}
extDevTools.call(ps);
var popup = ps.firstChild;
var e;
if(typeof event == "object" && event instanceof Event && "screenX" in event) // FireGestures
e = event;
else if(
this instanceof (Components.interfaces.nsIDOMChromeWindow || Components.interfaces.nsIDOMWindow)
&& "mgGestureState" in window && "endEvent" in mgGestureState // Mouse Gestures Redox
)
e = mgGestureState.endEvent;
else {
var anchor = this instanceof XULElement && this
|| window.gBrowser && gBrowser.selectedBrowser
|| document.documentElement;
if("boxObject" in anchor) {
var bo = anchor.boxObject;
e = {
screenX: bo.screenX,
screenY: bo.screenY
};
if(this instanceof XULElement)
e.screenY += bo.height;
}
else {
e = {
screenX: anchor.screenX || 0,
screenY: anchor.screenY || 0
};
}
}
var okEvt = e && ("screenX" in e);
if(!popup || !okEvt) {
alert(
"Mouse Gestures Launcher for Extensions Developer Tools:"
+ (!popup ? "\nNo popup! Missing or failed Extensions Developer Tools code." : "")
+ (!okEvt ? "\nCan't get event object!" : "")
);
destroy();
}
else {
if("openPopupAtScreen" in popup)
popup.openPopupAtScreen(e.screenX, e.screenY);
else
popup.showPopup(document.documentElement, e.screenX, e.screenY, "popup", null, null);
popup.addEventListener("popuphidden", destroy, false);
}
function destroy(e) {
if(e && e.target != popup)
return;
popup && popup.removeEventListener("popuphidden", destroy, false);
setTimeout(function() {
if("onDestroy" in ps) try {
ps.onDestroy("delete");
LOG("onDestroy()");
}
catch(e) {
Components.utils.reportError(e);
}
ps.parentNode.removeChild(ps);
LOG("Remove popup");
}, 0);
}
function extDevTools() {
//=== Extensions Developer Tools begin
//=== Extensions Developer Tools end
}
}).call(this);