-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
271 additions
and
29 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title>Granblue Autopilot</title> | ||
</head> | ||
<body> | ||
<!-- Viramate Web API --> | ||
<iframe id="viramate_api" src="chrome-extension://fgpokpknehglcioijejfeebigdnbnokj/content/api.html"></iframe> | ||
<script src="../dist/background.js"></script> | ||
</body> | ||
</html> |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import shortid from "shortid"; | ||
|
||
export default class ViramateApi { | ||
constructor(host) { | ||
this.host = host; | ||
this.pending = {}; | ||
window.addEventListener("message", ::this.onMessage, false); | ||
} | ||
|
||
generateId() { | ||
return shortid.generate(); | ||
} | ||
|
||
sendApiRequest(request, id) { | ||
id = id || this.generateId(); | ||
return new Promise((resolve, reject) => { | ||
request.id = id; | ||
this.pending[request.id] = {resolve, reject}; | ||
this.host.contentWindow.postMessage(request, "*"); | ||
}); | ||
} | ||
|
||
onMessage(evt) { | ||
if (evt.data.type !== "result") return; | ||
if (!evt.data.id) return; | ||
const promise = this.pending[evt.data.id]; | ||
if (!promise) return; | ||
|
||
if (evt.data.result && evt.data.result.error) { | ||
promise.reject(evt.data.result); | ||
} else { | ||
promise.resolve(evt.data.result); | ||
} | ||
|
||
delete this.pending[evt.data.id]; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,6 @@ export default { | |
window.location.hash = hash; | ||
window.setTimeout(() => { | ||
done("OK"); | ||
}, 5000); | ||
}, 1000); | ||
} | ||
}; |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
export default class RaidQueue { | ||
constructor() { | ||
this.queue = []; | ||
this.callbacks = []; | ||
} | ||
|
||
push(code) { | ||
if (this.callbacks.length > 0) { | ||
const callback = this.callbacks.shift(); | ||
callback(code); | ||
} else { | ||
this.queue.push(code); | ||
} | ||
} | ||
|
||
pop() { | ||
return new Promise((resolve) => { | ||
if (this.queue.length > 0) { | ||
resolve(this.queue.pop()); | ||
} else { | ||
this.callbacks.push(resolve); | ||
} | ||
}); | ||
} | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export default class WorkerManager { | ||
constructor(server, socket) { | ||
this.server = server; | ||
this.socket = socket; | ||
} | ||
|
||
stop() { | ||
this.server.stopSocket(this.socket.id); | ||
return this; | ||
} | ||
} |
This file contains 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
Oops, something went wrong.