forked from xifangczy/cat-catch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
firefox.js
40 lines (35 loc) · 1.2 KB
/
firefox.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
// 兼容Firefox的manifest V2
if (typeof (browser) == "object") {
chrome.action = browser.browserAction;
chrome.action.setBadgeText = browser.browserAction.setBadgeText;
chrome.action.setTitle = browser.browserAction.setTitle;
function importScripts() {
for (let script of arguments) {
const js = document.createElement('script');
js.src = script;
document.head.appendChild(js);
}
}
// Firefox scripting API 不完善
chrome.scripting = new Object();
chrome.scripting.executeScript = (obj) => {
return;
}
// browser.windows.onFocusChanged.addListener 少一个参数
chrome.windows.onFocusChanged.addListener = (listener, obj) => {
browser.windows.onFocusChanged.addListener(listener);
};
browser.runtime.onInstalled.addListener(({ reason }) => {
if (reason == "install") {
browser.tabs.create({ url: "privacy.html" });
}
});
if (typeof jQuery != "undefined") {
$('#firefoxYes').click(function () {
window.close();
});
$('#firefoxUninstallSelf').click(function () {
browser.management.uninstallSelf();
});
}
}