Created
May 8, 2017 00:04
-
-
Save otiai10/42e5fc29842d8235db1f814901e92fb5 to your computer and use it in GitHub Desktop.
艦これウィジェットのbackground updateのアラート機能(未採用)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/js/Components/Routine/LaunchPositionRecorder.js b/src/js/Components/Routine/LaunchPositionRecorder.js | |
index a90594c9..9ba72a9c 100644 | |
--- a/src/js/Components/Routine/LaunchPositionRecorder.js | |
+++ b/src/js/Components/Routine/LaunchPositionRecorder.js | |
@@ -5,19 +5,32 @@ export default class LaunchPositionRecorder { | |
this.context = context; | |
} | |
mainGameWindow(delay) { | |
- | |
- // contextがiframe内(parentを持ってる)なら、parentにやらせる | |
- if (this.context != this.context.parent) return; | |
- | |
- this.interval = setInterval(() => { | |
- this.client.message("/launchposition/:update", { | |
- left: this.context.screenX, | |
- top: this.context.screenY, | |
- architrave: { // エアロ領域とか言われる部分の大きさも記録しとく | |
- x: this.context.outerWidth - this.context.innerWidth, | |
- y: this.context.outerHeight - this.context.innerHeight, | |
- } | |
- }); | |
- }, delay); | |
+ // contextがiframe内(parentを持ってる)なら、parentにやらせる | |
+ if (this.context != this.context.parent) return Promise.resolve(); | |
+ return new Promise((resolve, reject) => { | |
+ this.interval = setInterval(() => { | |
+ this.client.message("/launchposition/:update", { | |
+ left: this.context.screenX, | |
+ top: this.context.screenY, | |
+ architrave: { // エアロ領域とか言われる部分の大きさも記録しとく | |
+ x: this.context.outerWidth - this.context.innerWidth, | |
+ y: this.context.outerHeight - this.context.innerHeight, | |
+ } | |
+ }).catch(err => reject(err)); | |
+ }, delay); | |
+ }); | |
} | |
+ static disconnectedMessage = [ | |
+ "艦これウィジェットが更新されたので、", | |
+ "この窓とChrome拡張のbackgroundとの接続が切れたっぽいです。\n\n", | |
+ "ユーザ各位はご存知のとおり、『艦これウィジェット』は", | |
+ "ゲームと接続はもともと一切してないので、", | |
+ "ゲームへの影響はありません。\n\n", | |
+ "Chrome拡張のbackgroundとの接続が切れているので、", | |
+ "スクショのショートカットキーとかが効かなくなってるはずです。\n\n", | |
+ "日頃からスクショショートカットキーを使っている方は、ウィジェットを", | |
+ "一回閉じてもっかいLAUNCHするのがいいと思います。", | |
+ "なお、スクショボタンや、ダッシュボードからのスクショは有効なので、今出撃中とかで", | |
+ "窓をリロードできないけどスクショとりたい場合はそっち使ってください。", | |
+ ].join(""); | |
} | |
diff --git a/src/js/entrypoints/pages/dmm.js b/src/js/entrypoints/pages/dmm.js | |
index 4b6254f1..ea32fae4 100644 | |
--- a/src/js/entrypoints/pages/dmm.js | |
+++ b/src/js/entrypoints/pages/dmm.js | |
@@ -3,8 +3,6 @@ import ExtractFlash from "../../Components/Routine/ExtractFlash"; | |
import {DecorateDMMPage} from "../../Components/Routine/DecoratePage"; | |
import LaunchPositionRecorder from "../../Components/Routine/LaunchPositionRecorder"; | |
-chrome.runtime.connect(); | |
- | |
import {Client} from "chomex"; | |
const client = new Client(chrome.runtime); | |
client.message("/window/should-decorate").then((res) => { | |
@@ -28,7 +26,9 @@ client.message("/window/should-decorate").then((res) => { | |
case FRAME_SHIFT: | |
DecorateDMMPage.init(window).decorate(res.tab.frame); | |
client.message("/window/zoom:set", {zoom: res.tab.frame.zoom}); | |
- (new LaunchPositionRecorder(client)).mainGameWindow(60 * 1000); | |
+ (new LaunchPositionRecorder(client)).mainGameWindow(15 * 1000).catch(() => { | |
+ window.alert(LaunchPositionRecorder.disconnectedMessage); | |
+ }); | |
client.message("/config/get", {key:"alert-on-before-unload"}).then(({data}) => { | |
if (data.value) onBeforeUnloadFuncs.push(() => true); | |
}); | |
diff --git a/src/js/entrypoints/pages/dsnapshot.js b/src/js/entrypoints/pages/dsnapshot.js | |
index 38f53bc1..ada1701b 100644 | |
--- a/src/js/entrypoints/pages/dsnapshot.js | |
+++ b/src/js/entrypoints/pages/dsnapshot.js | |
@@ -1,8 +1,6 @@ | |
import {Client, Router} from "chomex"; | |
import DamageSnapshotDisplay from "../../Components/Routine/DamageSnapshot"; | |
-chrome.runtime.connect(); | |
- | |
const client = new Client(chrome.runtime); | |
let snapshot = new DamageSnapshotDisplay(client); | |
diff --git a/src/js/entrypoints/pages/osapi.dmm.js b/src/js/entrypoints/pages/osapi.dmm.js | |
index 8bbb9d75..874cdf1c 100644 | |
--- a/src/js/entrypoints/pages/osapi.dmm.js | |
+++ b/src/js/entrypoints/pages/osapi.dmm.js | |
@@ -4,8 +4,6 @@ import DamageSnapshotDisplay from "../../Components/Routine/DamageSnapshot"; | |
import LaunchPositionRecorder from "../../Components/Routine/LaunchPositionRecorder"; | |
import InAppActionButtons from "../../Components/Routine/InAppActionButtons"; | |
-chrome.runtime.connect(); | |
- | |
import {Client} from "chomex"; | |
const client = new Client(chrome.runtime); | |
@@ -28,7 +26,9 @@ client.message("/config/get", {key: "use-inapp-action-buttons"}).then(({data}) = | |
window.onbeforeunload = () => onBeforeUnloadFuncs.map(f => f()).filter(r => !!r).length ? true : null; | |
}); | |
-(new LaunchPositionRecorder(client)).mainGameWindow(15 * 1000); | |
+(new LaunchPositionRecorder(client)).mainGameWindow(15 * 1000).catch(() => { | |
+ window.alert(LaunchPositionRecorder.disconnectedMessage); | |
+}); | |
let snapshot = new DamageSnapshotDisplay(client); | |
let router = new Router(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment