chrome-control

授权协议 MIT License
开发语言 JavaScript
所属分类 应用工具、 操作系统工具
软件类型 开源软件
地区 不详
投 递 者 贲宏硕
操作系统 OS X
开源组织
适用人群 未知
 软件概览

Chrome Control

A JXA script and an Alfred Workflow for controlling Google Chrome(Javascript for Automation). Also see my How I Navigate Hundreds of Tabs on Chrome with JXA and Alfred article if you're interested in learning how I created the workflow.

Usage

Make this file an executable

chmod +x ./chrome.js

Then run:

./chrome.js

MacOS will ask you to allow permissions for this tool to control Chrome.
Feel free to inspect the code before accepting.

Integration

You can use chrome-control to create fun integrations with your favorite tools (Alfred, vim, vscode, iterm2, ...).

Alfred

I've created an Alfred Workflow to use Chrome Control.You can find it under the intergrations directory.

Alfred Chrome Control commands:

  • tabs: Lists all tabs
  • close url <keywords>: Close tabs with URLs matching these keywords
  • close title <keywords>: Close tabs with titles matching these keywords
  • dedup: Close duplicate tabs

Commands

Close duplicate tabs

./chrome.js dedup

Close all tabs by titles containing strings

Strings are separated by spaces and case insensitive.

./chrome.js close --title "inbox" "iphone - apple"
./chrome.js close --title inbox iphone

Close all tabs by URLs containing strings

Strings are separated by spaces and case insensitive.

./chrome.js close --url "mail.google" "apple"
./chrome.js close --url google apple

List all open tabs in all Chrome windows

./chrome.js list

The output is JSON, so you can pipe it to jq.

./chrome.js list | jq .

Returns a struct like this:

{
  "items": [
    {
      "title": "Inbox (1) - <hidden>@gmail.com - Gmail",
      "url": "https://mail.google.com/mail/u/0/#inbox",
      "winIdx": 0,
      "tabIdx": 0,
      "arg": "0,0",
      "subtitle": "https://mail.google.com/mail/u/0/#inbox"
    },
    {
      "title": "iPhone - Apple",
      "url": "https://www.apple.com/iphone/",
      "winIdx": 0,
      "tabIdx": 1,
      "arg": "0,1",
      "subtitle": "https://www.apple.com/iphone/"
    }
  ]
}

arg and subtitle are used for Alfred integration.

Close a specific tab in a specific window

Window Index and Tab Index is the arg returned by the list command.

./chrome.js close 0,13

Focus on a specific tab in a specific window

./chrome.js focus 0,13

Show help

./chrome.js

Don't prompt the user

--yes flag will cause no questions to be asked to the user. It'll close all tabs straight away.

Attention: Use this with caution. Make sure you don't have any unsaved work, emails, ... etc.

Prompt user in Chrome

--ui flag will cause the questions to be asked using a Chrome dialog instead of text in command line.

./chrome.js close --url apple --ui

How did you create the banner and icon?

It took around 4 hours using Photoshop. I wanted to use Illustrator but I realized that I completely forgot how to use it.

Drawing the shapes are pretty easy but I spent most of the time on the following:

  • Picking harmonious colors.
  • Figuring out how to make it less dull, ended up using a shadow under the window which made a significant difference.
  • Figuring out how to represent the infrared waves.
  • Finding a way to export the PNG to ICNS.

Planning to write an article on that soon.

Bug Fixes & Pull Requests

If you find any bugs please feel to create an issue or create a pull request.

I can only accept pull requests to the source code and not the binary files for ensuring the repo stays sanitized. If you have any feature requests for the workflow, I'd be happy to add them in after a discussion.

License

Copyright (c) 2019 Renan Cakirerk

Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.

  • 描述 同一个标签页,打开 A 站点,访问 config 接口,正常;打开 B 站点,访问 config 接口,正常;通过浏览器后退返回 A 站点,访问 config 接口,数据异常,config 返回了 B 站点的数据。 测试站点数据 https://a.aaa.com https://b.bbb.com 分析 判断是否是前端问题 通过观察,后退时仍然向服务器发送了请求,调用了 config 接口

  • 解决方案: 打开mac上的终端,输入 open -n /Applications/Google\ Chrome.app/ --args --disable-web-security --user-data-dir=/Users/xxx/Documents/ChromeDevData Tips:输入执行这段代码后会打开一个新的谷歌浏览器,将刚刚跨域的页面地址拷贝到该浏览器访问即可,同时会在 /Use

  • 问题背景 重置了阿里云服务器,安装google chrome报错。 sudo apt-get install -f sudo dpkg -i google-chrome*.deb 报错内容如下: (Reading database ... 113300 files and directories currently installed.) Preparing to unpack google-c

  • 服务端设置响应头 // 单位是【秒】 Access-Control-Max-Age:1800 // 禁用options请求 Access-Control-Max-Age:-1 参考 减少options请求次数以及前端post请求未发送options请求

  • Allow CORS: Access-Control-Allow-Origin插件安装与使用教程【Chrome插件小白式教程】 插件介绍 解决Chrome浏览器跨域的问题,2021年1月14日,确保能用。 QQ群:819539788 插件下载 CSDN论坛下载地址 官方的链接,可能会有朋友无法下载,别方,我准备了国内的下载地址: 关注微信公众号获取下载地址。

  • 前言 除非特别说明,否则以下内容和结论均经过实际测试并验证,测试用的浏览器:Google Chrome 98.0.4758.102正式版。 例子 先看下响应头Cache-Control的一些常见用法。 第一种:Cache-Control:max-age=N 浏览器获取到资源内容后,将资源内容缓存在本地,缓存有效期是N秒。 若过期前再次访问资源,直接使用本地缓存;过期后再访问,则向服务器发请求,若服

  • 首先,缓存问题依靠html的meta标签解决是不靠谱的,一般大型网站都依靠nginx server在 http头中对静态资源设置缓存。 而影响缓存的http头有好几个,尽管http 1.1协议之后,从协议本身的规范的角度可以认为 只要有cache-control这个头存在,pragma expires就无效了,但你不能相信所有浏览器所有版本都完全按照标准进行了实现,所以,比较职业的做法是把所有该下

  • Access-Control-Allow-Credentials Access-Control-Allow-Credentials响应报头指示的请求的响应是否可以暴露于该页面。当true值返回时它可以被暴露。 凭证是 Cookie ,授权标头或 TLS 客户端证书。 当作为对预检请求的响应的一部分使用时,它指示是否可以使用凭证进行实际请求。请注意,简单的GET请求不是预检的,所以如果请求使用凭证的

  •   关于Pragma:no-cache,跟Cache-Control: no-cache相同。Pragma: no-cache兼容http 1.0 ,Cache-Control: no-cache是http 1.1提供的。 因此,Pragma: no-cache可以应用到http 1.0 和http 1.1,而Cache-Control: no-cache只能应用于http 1.1   HTTP协

  • 我正在开发一个页面,该页面通过jQuery的AJAX支持从Flickr和Panoramio中提取图像。 Flickr方面运行良好,但是当我尝试从Panoramio进行$.get(url, callback)时,我在Chrome的控制台中看到一个错误: XMLHttpRequest无法加载http://www.panoramio.com/wapi/data/get_photos?v=1&key=du

 相关资料
  • 使用chrome调试android前端页面 下载Chrome浏览器 官方教程:remote-debugging 开源工具Stetho 功能: 安卓远程调试目前支持所有操作系统(Windows,Mac, Linux, and Chrome OS.)中调试,支持: 调试站点的页面 调试安卓原生App中的WebView 实时将安卓设备的屏幕图像同步显示到开发机器。 通过端口转发(port forward

  • Chrome 是 Google 做的浏览器。 https://www.google.com/chrome/ 安装 国内打开 Google 网站会遇到网络问题,你需要想想办法 :) 或者直接在百度搜索 Chrome 浏览器,在一些靠谱的下载网站去下载 Chrome。也可以试一下使用系统包管理工具去安装 Chrome。 Windows 用 chocolatey 安装 Chrome: choco ins

  • Google Chrome,又称谷歌浏览器,是一个由Google(谷歌)公司开发的网页浏览器。本软件的程式码是基于其他开放源代码软件所撰写,包括WebKit和Mozilla,目标是提升稳定性、速度和安全性,并创造出简单且有效率的使用者界面。软件的名称是来自于又称作“Chrome”的网络浏览器图形使用者界面(GUI)。 Chrome相应的开放源代码计划名为Chromium,而Google Chrom

  • 查看[Chrome OS设计文档相关章节](https://www.chromium.org/chromium-os/chromiumos-design-docs)

  • 第一章 Chrome开发者工具 * 2017-11-17 白鹏飞 增加调试工具的一些实用技巧,增加与Firefox对比 1.1 Chrome Devtools 概述 Chrome开发工具(又称DevTools),是一套内嵌在chrome浏览器内部的web编写和调试工具。DevTools提供给web开发人员深入地访问浏览器内部和web应用的机会。DevTools可以有效地 跟踪布局问题 , 设置J

  • 使用 Headless Chrome 渲染 JavaScript 前端渲染的网页(如 AngularJS)以便搜索引擎爬取。 安装 Chrome Headless Chrome Headless 浏览器可以使用 Docker 轻松安装: $ docker pull yukinying/chrome-headless 启动 Chrome Headless $ docker run -i -t --s