-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
43 lines (28 loc) · 737 Bytes
/
background.js
File metadata and controls
43 lines (28 loc) · 737 Bytes
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
var _browser = chrome;
var GA_TRACKING_ID = 'UA-112771980-1';
// Helpers
function uuidv4 () {
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
)
}
// New tab
function openNewTab (url) {
_browser.tabs.create({
url: url
});
}
// Context Menu
_browser.contextMenus.create({
id: "verify-link",
title: 'Bingle Proxy',
contexts: ["link"]
});
_browser.contextMenus.onClicked.addListener(function(info, tab) {
var url = 'https://www.bingle.pw/' + info.linkUrl + '&submit=1';
openNewTab(url);
});
// Toolbar button
_browser.browserAction.onClicked.addListener(function () {
openNewTab('https://www.bingle.pw');
});