-
Notifications
You must be signed in to change notification settings - Fork 0
/
content.js
36 lines (29 loc) · 1.26 KB
/
content.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
// function hideDom () {
// if (document.querySelector('style[brisk]')) return
// let style = document.createElement('style')
// style.setAttribute('type', 'text/css')
// style.setAttribute('brisk', true)
// style.innerHTML = ".wbpro-side.woo-panel-main.woo-panel-top.woo-panel-right.woo-panel-bottom.woo-panel-left.Card_wrap_2ibWe.Card_bottomGap_2Xjqi:first-child { display:none }"
// document.head.appendChild(style)
// }
// let mutationObserver = window.MutationObserver
// let observer = new MutationObserver(hideDom)
// observer.observe(document, { childList: true, subtree: true })
// 在页面上插入代码
const script = document.createElement('script');
script.setAttribute('type', 'text/javascript');
script.setAttribute('src', chrome.extension.getURL('request_interceptor.js'));
document.documentElement.appendChild(script);
script.addEventListener('load', () => {
chrome.storage.sync.get({
keywords: '',
usernames: ''
}, (result) => {
if (result.keywords) {
postMessage({ type: 'ajaxInterceptor', to: 'pageScript', key: 'keywords', value: result.keywords.split(',') });
}
if (result.usernames) {
postMessage({ type: 'ajaxInterceptor', to: 'pageScript', key: 'usernames', value: result.usernames.split(',') });
}
});
});