Skip to content

Commit

Permalink
Optimize "new_tab_disable"
Browse files Browse the repository at this point in the history
  • Loading branch information
Bush2021 committed Nov 2, 2023
1 parent b2a942c commit 3de70e4
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 23 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Right-click and scroll the tab bar.
* New foreground tab opens the contents entered in address bar.
* New foreground tab opens bookmarks.
* Disable the above two features when the current tab is a new tab. (Since the identification of new tabs is based on the name, support for the corresponding language is required. If you encounter an unsupported situation, you can submit an issue)
* Disable the above two features when the current tab is a new tab.
* Use hotkeys to quickly hide the browser window (boss key).
* Portable design: the program is placed in the App directory, and data is stored in the Data directory (incompatible with the original data; you can reinstall the system or change computers without losing data).
* Allow configuration of features using ini files.
Expand Down
2 changes: 1 addition & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ English instruction: https://github.com/Bush2021/chrome_plus/blob/main/README.md
- 按住右键时滚轮滚动标签栏
- 新建前台标签页打开地址栏输入的内容
- 新建前台标签页打开书签
- 当前为新标签页时,可以禁用上面两个功能(由于新标签页的识别是通过名称,所以需要对应语言的支持,如果遇到不支持的情况可以提交 issue)
- 当前为新标签页时,可以禁用上面两个功能
- 使用快捷键快速隐藏浏览器窗口(老板键)
- 便携设计,程序放在 App 目录,数据放在 Data 目录(不兼容原版数据,可以重装系统换电脑不丢数据)
- 可以使用 ini 文件配置功能
Expand Down
53 changes: 32 additions & 21 deletions src/TabBookmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -578,32 +578,43 @@ bool IsOnNewTab(NodePtr top)
else
{
bool flag = false;
wchar_t *new_tab_name = NULL;
NodePtr PageTabList = FindPageTabList(top);
if (PageTabList)
{
NodePtr PageTab = FindPageTab(PageTabList);
if (PageTab)
{
NodePtr PageTabPane = GetParentElement(PageTab);
if (PageTabPane)
TraversalAccessible(PageTabList, [&new_tab_name](NodePtr child) {
if (GetAccessibleRole(child) == ROLE_SYSTEM_PUSHBUTTON)
{
GetAccessibleName(child, [&new_tab_name](BSTR bstr) {
new_tab_name = bstr;
DebugLog(L"new_tab_name: %s", bstr);
});
}
return false;
});
}
{
NodePtr PageTab = FindPageTab(PageTabList);
if (PageTab)
{
TraversalAccessible(PageTabPane, [&flag](NodePtr child) {
if (GetAccessibleRole(child) == ROLE_SYSTEM_PAGETAB)
{
GetAccessibleName(child, [&flag](BSTR bstr) {
if (wcscmp(bstr, L"New Tab") == 0 || wcscmp(bstr, L"Новая вкладка") == 0 || wcscmp(bstr, L"新标签页") == 0)
{
DebugLog(L"NewTab bstr: %s", bstr);
flag = true;
}
else
{
DebugLog(L"NotNewTab bstr: %s", bstr);
}
});
}
return flag;
});
NodePtr PageTabPane = GetParentElement(PageTab);
if (PageTabPane)
{
TraversalAccessible(PageTabPane, [&flag, &new_tab_name](NodePtr child) {
if (GetAccessibleRole(child) == ROLE_SYSTEM_PAGETAB)
{
GetAccessibleName(child, [&flag, &new_tab_name](BSTR bstr) {
if (wcscmp(bstr, new_tab_name) == 0)
{
DebugLog(L"Found PageTab with name: %s", bstr);
flag = true;
}
});
}
return flag;
});
}
}
}
}
Expand Down

0 comments on commit 3de70e4

Please sign in to comment.