-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
47 lines (43 loc) · 1.54 KB
/
background.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
chrome.runtime.onMessage.addListener( function (request, sender, sendResponse) {
if (request.refresh) {
window.location = window.location
} else if (request.thispage) {
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
var currTab = tabs[0];
if (currTab) {
chrome.tabs.executeScript(currTab.id, { file: 'auto.js' });
}
});
}
})
chrome.storage.sync.get('status', function (res) {
console.log(res.status)
if (res.status) {
chrome.webRequest.onBeforeRequest.addListener(
function (details) {
console.log(details)
if (details.url) {
const status = details.url.includes('.gif') && !details.url.includes('cleardot')
if (status) {
code = 'document.querySelector("img[src='+"'"+details.url+"'"+']").setAttribute("style", "display: none;")'
chrome.tabs.executeScript(details.tabId, { code: code });
return { cancel: true }
}
}
},
{
urls: ["<all_urls>"]
},
["blocking"]
);
}
})
chrome.tabs.onUpdated.addListener(function (tabId, info) {
if (info.status == 'complete') {
console.log('completed')
chrome.tabs.executeScript(tabId, { file: 'auto.js' });
}
});
chrome.runtime.onInstalled.addListener(function (object) {
chrome.storage.sync.set({ status: true })
});