forked from stoodkev/SteemPlus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
executable file
·86 lines (81 loc) · 2.98 KB
/
background.js
File metadata and controls
executable file
·86 lines (81 loc) · 2.98 KB
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
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
console.log("bgs: forwarded " + request.data + " to the tab " + request.to);
if (request.command !== undefined) websiteSwitch(request.command)
else {
chrome.tabs.query({
active: true,
currentWindow: true
}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, request, function(response) {});
});
}
});
chrome.commands.onCommand.addListener(function(command) {
console.log(command);
websiteSwitch(command);
});
function websiteSwitch(command) {
chrome.tabs.query({
'active': true,
'lastFocusedWindow': true
}, function(tabs) {
var url = tabs[0].url;
var web = '';
if (url.includes('busy.org')) web = 'busy.org';
if (url.includes('utopian.io')) web = 'utopian.io';
if (url.includes('steemit.com')) web = 'steemit.com';
if (url.includes('steemd.com')) web = 'steemd.com';
if (command === 'steemify') {
if (web == 'busy.org' || web == 'utopian.io' || web == 'steemd.com') {
chrome.tabs.query({
active: true,
currentWindow: true
}, function(tabs) {
var code = url.replace(web, 'steemit.com');
chrome.tabs.update(tabs[0].id, {
url: code
});
});
}
}
if (command === 'utopify') {
if (web == 'busy.org' || web == 'steemit.com' || web == 'steemd.com') {
chrome.tabs.query({
active: true,
currentWindow: true
}, function(tabs) {
var code = url.replace(web, 'utopian.io');
chrome.tabs.update(tabs[0].id, {
url: code
});
});
}
}
if (command === 'busyfy') {
if (web == 'steemit.com' || web == 'utopian.io' || web == 'steemd.com') {
chrome.tabs.query({
active: true,
currentWindow: true
}, function(tabs) {
var code = url.replace(web, 'busy.org');
chrome.tabs.update(tabs[0].id, {
url: code
});
});
}
}
if (command === 'steemdify') {
if (web == 'busy.org' || web == 'utopian.io' || web == 'steemit.com') {
chrome.tabs.query({
active: true,
currentWindow: true
}, function(tabs) {
var code = url.replace(web, 'steemd.com');
chrome.tabs.update(tabs[0].id, {
url: code
});
});
}
}
});
}