Skip to content

Commit

Permalink
Merge pull request #33 from xoFeulB/v0.5
Browse files Browse the repository at this point in the history
_
  • Loading branch information
ibuninngu authored Mar 10, 2024
2 parents 8322c14 + b70f977 commit 50f6307
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
48 changes: 43 additions & 5 deletions js/bluefox.script.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,37 @@ class Tab {
this.isDebugging = false;
}
async setUserAgentOverride(parameters) {
// https://chromedevtools.github.io/devtools-protocol/tot/Network/#method-setUserAgentOverride
// https://chromedevtools.github.io/devtools-protocol/tot/Emulation/#method-setUserAgentOverride
return await this.sendCommand(
"Network.setUserAgentOverride",
"Emulation.setUserAgentOverride",
parameters
);
}
async emulateNetworkConditions(parameters) {
// https://chromedevtools.github.io/devtools-protocol/tot/Network/#method-emulateNetworkConditions
return await this.sendCommand(
"Network.emulateNetworkConditions",
parameters
);
}
async setCPUThrottlingRate(parameters) {
// https://chromedevtools.github.io/devtools-protocol/tot/Emulation/#method-setCPUThrottlingRate
return await this.sendCommand(
"Emulation.setCPUThrottlingRate",
parameters
);
}
async setDeviceMetricsOverride(parameters) {
// https://chromedevtools.github.io/devtools-protocol/tot/Emulation/#method-setDeviceMetricsOverride
return await this.sendCommand(
"Emulation.setDeviceMetricsOverride",
parameters
);
}
async setTimezoneOverride(parameters) {
// https://chromedevtools.github.io/devtools-protocol/tot/Emulation/#method-setTimezoneOverride
return await this.sendCommand(
"Emulation.setTimezoneOverride",
parameters
);
}
Expand Down Expand Up @@ -280,14 +308,14 @@ class Tab {
}

export class BlueFoxScript extends (Object) {
constructor() {
constructor(option) {
super();
return new Promise((resolve, reject) => {
this.init(resolve);
this.init(resolve, option);
});
}

async init(resolve) {
async init(resolve, option = {}) {
/* Tab */{
chrome.debugger.onDetach.addListener(
async (source, reason) => {
Expand Down Expand Up @@ -329,11 +357,21 @@ export class BlueFoxScript extends (Object) {
async (tabInfo) => {
this[tabInfo.id] = new Tab(tabInfo);
await this[tabInfo.id].attachDebugger();
Object.entries(option).forEach(([key, value]) => {
if (key in this[tabInfo.id]) {
this[tabInfo.id][key](value);
}
});
}
);

[...(await chrome.tabs.query({ url: "<all_urls>" }))].forEach((tabInfo) => {
this[tabInfo.id] = new Tab(tabInfo);
Object.entries(option).forEach(([key, value]) => {
if (key in this[tabInfo.id]) {
this[tabInfo.id][key](value);
}
});
});
}

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.0",
"version": "0.5.1",
"description": "Agile Web Automation Software for Time-Starved Professionals",
"host_permissions": [
"<all_urls>"
Expand Down

0 comments on commit 50f6307

Please sign in to comment.