Skip to content

Commit

Permalink
Merge pull request #34 from xoFeulB/v0.5
Browse files Browse the repository at this point in the history
_
  • Loading branch information
ibuninngu committed Mar 11, 2024
2 parents 50f6307 + b194163 commit 622e119
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
28 changes: 18 additions & 10 deletions background/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@

{
(async () => {
let log = (...args) => {
console.log("background.js", ...args);
};
log("loaded");
let log = console.log;

let R = {
pageInfo: {},
Expand Down Expand Up @@ -217,12 +214,23 @@
},
};

chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
actions[message.type](message.object, sender).then((response) => {
sendResponse(response);
});
return true;
});
chrome.runtime.onMessage.addListener(
(message, sender, sendResponse) => {
if (message.type in actions) {
(async () => {
try {
let R = await actions[message.type](message.object, sender);
sendResponse(R);
} catch (e) {
sendResponse(e);
}
})();
return true;
} else {
return false;
}
}
);

chrome.tabs.onRemoved.addListener((tabId) => {
delete R.event_observer[tabId];
Expand Down
4 changes: 3 additions & 1 deletion js/websocket.awaitable.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export class AwaitbleWebSocket {
this.messagePool = {};
this.isOpen = false;
let _resolve_ = () => { };
let _reject_ = () => { };

this.socket.addEventListener("open", (event) => {
this.isOpen = true;
Expand All @@ -25,11 +26,12 @@ export class AwaitbleWebSocket {
});
this.socket.addEventListener("error", (event) => {
this.isOpen = false;
_resolve_(this);
_reject_(event);
});

return new Promise((resolve, reject) => {
this.isOpen ? resolve(this) : _resolve_ = resolve;
_reject_ = reject;
});
}

Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "^.,.^ BlueFox",
"version": "0.5.1",
"version": "0.5.2",
"description": "Agile Web Automation Software for Time-Starved Professionals",
"host_permissions": [
"<all_urls>"
Expand Down
3 changes: 0 additions & 3 deletions tab/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,6 @@ window.BlueFoxScript = class extends BlueFoxScript {
try {
webSocket?.close();
webSocket = await (new AwaitbleWebSocket(`ws://${Values.values.BluefoxServer.value}:8888`));
if (!webSocket.isOpen) {
throw new Error();
}
let webSocketMessageHandler = {
"getFileTree": async (data) => {
document.querySelector("[vscode-notice]").setAttribute("hide", "");
Expand Down
11 changes: 2 additions & 9 deletions tab/js/init.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
(async () => {
let sendMessage = async (arg) => {
try {
return await chrome.runtime.sendMessage(arg);
} catch (err) {
log(err);
}
};
{
let attach_result = await sendMessage({
let attach_result = await chrome.runtime.sendMessage({
type: "Debugger.attach",
});
let evaluate_result = await sendMessage({
let evaluate_result = await chrome.runtime.sendMessage({
type: "Runtime.evaluate",
object: {
expression: `(()=>{return "^.,.^ BlueFox";})();`,
Expand Down

0 comments on commit 622e119

Please sign in to comment.