|
@@ -13,9 +13,12 @@ import {
|
|
|
setMessageCount,
|
|
|
discordLoginCode,
|
|
|
saveDiscordAuthWindowId,
|
|
|
- onDisconnectHandler
|
|
|
+ onDisconnectHandler,
|
|
|
+ getMessageInfo
|
|
|
} from "@/logic/background/twitter";
|
|
|
|
|
|
+import { PingPong } from "@/logic/background/help";
|
|
|
+
|
|
|
import {
|
|
|
facebookShareSuccess
|
|
|
} from "@/logic/background/facebook";
|
|
@@ -39,10 +42,31 @@ chrome.runtime.onInstalled.addListener(onInstalledMethod);
|
|
|
|
|
|
chrome.runtime.onMessage.addListener(onMessageMethod);
|
|
|
|
|
|
+// 定时器
|
|
|
+chrome.alarms.onAlarm.addListener(function (alarm) {
|
|
|
+ // console.log("onAlarm-", alarm);
|
|
|
+ switch (alarm.name) {
|
|
|
+ case 'denetChromeAlarm':
|
|
|
+ getMessageInfo();
|
|
|
+ break
|
|
|
+ case 'PingPong':
|
|
|
+ PingPong()
|
|
|
+ break;
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
function onInstalledMethod() {
|
|
|
onInstalledCreateTab()
|
|
|
onInstalledMid()
|
|
|
onInstalledUserSet()
|
|
|
+
|
|
|
+ // pingpang
|
|
|
+ chrome.alarms.create('PingPong', {
|
|
|
+ //1分鐘之後開始(該值不能小於1)
|
|
|
+ delayInMinutes: 2,
|
|
|
+ //開始後每一分鐘執行一次(該值不能小于1)
|
|
|
+ periodInMinutes: 4
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
function onMessageMethod(req, sender, sendResponse) {
|
|
@@ -87,6 +111,9 @@ function onMessageMethod(req, sender, sendResponse) {
|
|
|
case 'CONTENT_FACEBOOK_SHARE_SUCCESS':
|
|
|
facebookShareSuccess(req, sender);
|
|
|
break;
|
|
|
+ case 'CONTENT_PONG':
|
|
|
+ console.log('CONTENT_PONG')
|
|
|
+ break
|
|
|
}
|
|
|
}
|
|
|
}
|