2023 年 chrome 浏览器调教脚本分享,右键居中tab搜索弹窗

201 阅读3分钟

因为 是用自己开发的扩展,而不想每次启动都有提示卸载的弹窗,所以我用的是 chrome dev 版本,外加 edge 浏览器,双持。

然而,这两个浏览器都会后台默默更新,导致越来越难用。比如,edge 浏览器之前有个开关,开启后,可以允许后台运行 timer 定时器,后来就没了,导致浏览器窗口被遮住,就不能持续运行定时器了。

而 chrome dev 这段时间的变化更大。有好有坏。好的是 字体变大了,右键菜单变大,但是字体黑体,有点发糊。

坏的是某些更新会打破习惯。比如,搜索标签页的按钮原来放右边,现在移至最左边。再比如,标签页栏与窗口顶部多了点击间隙。下面分享一些调教技巧。

AHK 优化 搜索标签页,使之更加易用

修改快捷键

原快捷键为: ctrl + shift + a,可改为 alt + e 之类

is_wnd_tab_list(){
	WinGetPos,x,y,w,h, A
	if(w > 500 && w < 600) {
		WinGetTitle, title, A
		if(title="") {
			return 1
		}
	}
	return 0
}
center_tab_list(){
	sleep, 80
	is_wnd := is_wnd_tab_list()=1
	if(!is_wnd)  {
		sleep, 80
		is_wnd := is_wnd_tab_list()=1
	}
	if(!is_wnd)  {
		sleep, 80
		is_wnd := is_wnd_tab_list()=1
	}
	if(!is_wnd)  {
		sleep, 80
		is_wnd := is_wnd_tab_list()=1
	}
	if(!is_wnd)  {
		return
	}
	;消息(is_wnd, 500)
	MouseGetPos, xpos, ypos
	WinMove, A,, xpos-250, Top,,
}

!E::
	Send ^+{A}
	center_tab_list()
return

右键顶部任意位置打开

还可以右键顶部任意位置打开。原本右键顶部,一般是打开标签页的菜单,复制标签页之类,一般不是很常用。于是,可以将右键顶部改成打开 “搜索标签页” 界面,效果还行,截图如下:

优化后,“搜索标签页” 界面跟随鼠标位置,居中:

AHK 调整窗口位置,去除顶部点击间隙

F8::
	WinMove, ahk_class Chrome_WidgetWin_1,, -15, -18, A_ScreenWidth+35, A_ScreenHeight-25
	消息("clipboard", "w550")
Return

效果一般,需退出最大化使用

定制 Black theme 主体扩展,高亮当前标签页

chrome 更新那么久,但是最基础的,高亮标签页确还没有,需要安装第三方扩展。

但这个扩展会修改整体窗口样式,而我只想要一个标签页的高亮条即可。

分享定制方法如下:

文档:docs.google.com/document/d/…

chrome theme 扩展直接用 manifest 定义,比如:

{
"update_url": "https://clients2.google.com/service/update2/crx",

   "description": "Black theme red highlighted active tab.",
   "manifest_version": 2,
   "name": "Black theme with red highlighted active tab",
   "theme": {
      "colors": {
      },
      "images": {
		"theme_toolbar": "images/theme_toolbar.png",
         "theme_tab_background": "images/theme_tab_background.png"
      },
      "properties": {
         "ntp_background_alignment": "bottom",
         "ntp_background_repeat": "no-repeat",
         "ntp_logo_alternate": "0"
      }
   },
   "version": "1.0.0"
}

其中 theme_tab_background 定义背景顶栏,标签页的背景图片。 theme_toolbar 则定义了当前标签页,连着地址栏,连着书签栏的颜色。

无法直接定制当前标签页的高亮色,必须连地址栏一起。

导致为了突出当前标签页,必须让背景标签页发灰。


2023年8月19日 更新,chrome dev有更新了,又改回去了

下载的右键居中tab搜索弹窗的ahk函数是这样:

center_tab_list(){
	MouseGetPos, xpos, ypos
	sleep, 80
	is_wnd := is_wnd_tab_list()=1
	if(!is_wnd)  {
		sleep, 80
		is_wnd := is_wnd_tab_list()=1
	}
	if(!is_wnd)  {
		sleep, 80
		is_wnd := is_wnd_tab_list()=1
	}
	if(!is_wnd)  {
		sleep, 80
		is_wnd := is_wnd_tab_list()=1
	}
	if(!is_wnd)  {
		return
	}
	;sleep, 500
	is_wnd := is_wnd_tab_list()=1
	;消息(is_wnd, 500)
	WinMove, A,, xpos-250, Top,,
}