Skip to content

Commit

Permalink
0.4.0 (2024/08/06)
Browse files Browse the repository at this point in the history
  - Fixed for Coze layout change.
  - Add new shortcuts for the `Bot Store`(`1`), `Plugin Store`(`2`), and `Workflow Store`(`3`) pages.
  - Add new shortcuts for the `+ Create bot` (`c`) dialog and `Message Credits` (`s`) dialog.
  • Loading branch information
doggy8088 committed Aug 5, 2024
1 parent 0acd5d8 commit 782bd99
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 33 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

- 0.4.0 (2024/08/06)

- Fixed for Coze layout change.
- Add new shortcuts for the `Bot Store`(`1`), `Plugin Store`(`2`), and `Workflow Store`(`3`) pages.
- Add new shortcuts for the `+ Create bot` (`c`) dialog and `Message Credits` (`s`) dialog.

- 0.3.0 (2024/08/04)

- Bug fixed: When the keyboard cursor is at `isContentEditable`, do not trigger the shortcut key.
Expand Down
4 changes: 2 additions & 2 deletions PUBLISH.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Pubilsh Notes

1. Simply zip whole folder as a zip file such as `cozeshortcuts_v0.3.0.zip`
1. Simply zip whole folder as a zip file such as `cozeshortcuts_v0.4.0.zip`

```sh
7z a cozeshortcuts_v0.3.0.zip _locales images scripts CHANGELOG.md manifest.json README.md
7z a cozeshortcuts_v0.4.0.zip _locales images scripts CHANGELOG.md manifest.json README.md
```

2. Publish to Chrome Web Store.
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ Currently provides the following shortcuts:

- Press `h` to open the `Home` page
- Press `p` to open the `Personal` page
- Press `s` to open the `Manage Subscription` page
- Press `t` to switch between different Teams projects, and press `Enter` to enter the page
- Press `1` to open the `Bot Store` page
- Press `2` to open the `Plugin Store` page
- Press `3` to open the `Workflow Store` page
- Press `c` to open the `+ Create bot` dialog. Hit `Escape` to close the dialog.
- Press `s` to open the `Message Credits` dialog. Hit `Escape` to close the dialog.
- Press `alt+p` to open the `My profile` page
- Press `alt+1` to switch the tab above on the Space page: `Bots`
- Press `alt+2` to switch the tab above on the Space page: `Plugins`
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 3,
"name": "__MSG_cozeshortcuts_name__",
"description": "__MSG_cozeshortcuts_description__",
"version": "0.3.0",
"version": "0.4.0",
"default_locale": "zh_TW",
"author": "__MSG_cozeshortcuts_author__",
"icons": {
Expand Down
61 changes: 32 additions & 29 deletions scripts/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

// 檢查是否按下了 Alt 鍵和 S 鍵
if (!event.altKey && (event.key === 's' || event.key === 'S')) {
performActions_UserSubMenu('Manage Subscription');
performActions('Message Credits');
}
if (!event.altKey && (event.key === 'p' || event.key === 'P')) {
performActions('Personal');
Expand All @@ -52,17 +52,34 @@
findAndToggleTeams();
}

if (!event.altKey && (event.key === '1')) {
performActions('Bot Store');
}

if (!event.altKey && (event.key === '2')) {
performActions('Plugin Store');
}

if (!event.altKey && (event.key === '3')) {
performActions('Workflow Store');
}

if (event.altKey && (event.key === 'p' || event.key === 'P')) {
console.log('Alt + P')
performActions_UserSubMenu('My profile');
}

if (event.altKey && (parseInt(event.key) >= 1 && parseInt(event.key) <= 5)) {
var elm = findTestId('bot.tab');
if (elm) {
console.log('Alt + ' + event.key, [...elm.parentElement.children].filter(x => x.tagName === 'A'));
[...elm.parentElement.children].filter(x => x.tagName === 'A')?.[parseInt(event.key) - 1]?.click();
}
}

if (!event.altKey && (event.key === 'c' || event.key === 'C')) {
performActions('Create bot');
}
});

// 函數:查找包含特定文本的DOM節點並觸發mousedown事件
Expand Down Expand Up @@ -104,19 +121,12 @@
for (let i = 0; i < elements.snapshotLength; i++) {
let element = elements.snapshotItem(i);
if (element) {
// 向上遍歷DOM樹,查找帶有tabindex屬性的節點
while (element && !element.hasAttribute('tabindex')) {
element = element.parentElement;
}

if (element) {
element.click();
console.log(`Clicked element containing "${text}"`);

return true;
} else {
console.log(`Found text "${text}", but no parent element with tabindex`);
}
element.click();
element?.parentElement?.parentElement?.scrollIntoView()
console.log(`Clicked element containing "${text}"`);
return true;
} else {
console.log(`Found text "${text}", but no parent element with tabindex`);
}
}

Expand All @@ -136,20 +146,13 @@
for (let i = 0; i < elements.snapshotLength; i++) {
let element = elements.snapshotItem(i);
if (element) {
// 向上遍歷DOM樹,查找帶有tabindex屬性的節點
while (element && !element.hasAttribute('tabindex')) {
element = element.parentElement;
}

if (element) {
console.log(element)
element?.parentElement?.parentElement?.nextSibling?.click();
console.log(`Clicked element containing "${text}" and get it's next sibling`);
console.log(element)
element?.parentElement?.parentElement?.nextSibling?.click();
console.log(`Clicked element containing "${text}" and get it's next sibling`);

return true;
} else {
console.log(`Found text "${text}", but no parent element with tabindex`);
}
return true;
} else {
console.log(`Found text "${text}", but no parent element with tabindex`);
}
}

Expand Down Expand Up @@ -230,10 +233,10 @@
}

async function performActions_UserSubMenu(clickstr) {
findParentTabindexAndNexItemAndClickElement('Coze token');
findParentTabindexAndNexItemAndClickElement('Coze API');
await new Promise(resolve => setTimeout(resolve, 100));
findAndTriggerMouseDown(clickstr);
findParentTabindexAndNexItemAndClickElement('Coze token');
findParentTabindexAndNexItemAndClickElement('Coze API');
}

})();

0 comments on commit 782bd99

Please sign in to comment.