后台获取数据. 获取内容完成. TODO: 注册型客户端.
This commit is contained in:
51
chromeproxy/content/inject.js
Normal file
51
chromeproxy/content/inject.js
Normal file
@@ -0,0 +1,51 @@
|
||||
|
||||
|
||||
chrome.runtime.onMessage.addListener(function (request) {
|
||||
switch(request.type) {
|
||||
case InjectMsgType.WAIT:
|
||||
setTimeout(function(){
|
||||
GetTask();
|
||||
}, 6000);
|
||||
break;
|
||||
case InjectMsgType.NOTASK:
|
||||
setTimeout(function(){
|
||||
GetTask();
|
||||
}, 4000);
|
||||
break;
|
||||
case InjectMsgType.FETCH:
|
||||
setTimeout(function(){
|
||||
GetTask();
|
||||
}, 6000)
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
var href = window.location.href;
|
||||
var content = document.documentElement.innerHTML;
|
||||
if (href.startsWith("https://playerduo.com") && content.startsWith('<head></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">')) {
|
||||
Tell(BackgroundMsgType.CONTENT, content);
|
||||
} else {
|
||||
Tell(BackgroundMsgType.NOTWANT, content);
|
||||
}
|
||||
|
||||
function Tell(backgroundType, content) {
|
||||
if(content == undefined) {
|
||||
chrome.runtime.sendMessage({type: backgroundType});
|
||||
} else {
|
||||
chrome.runtime.sendMessage({type: backgroundType, content: content});
|
||||
}
|
||||
}
|
||||
|
||||
function GetTask() {
|
||||
Tell(BackgroundMsgType.GETTASK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user