javascript - 是否可以从查看源页面上的 Chrome 扩展程序运行内容脚本?

标签 javascript google-chrome google-chrome-extension

我正在开发一个 Chrome 扩展程序,它运行一些内容脚本并修改查看页面的 HTML/CSS。扩展程序是否可以访问“view-source: https://stackoverflow.com/”之类的查看源 URL 并修改其源?一个示例场景是我希望打开的每个 View 源页面上的字体为 20 磅和蓝色。 match patterns 上没有提及此行为文档页面。

最佳答案

不,您将无法在 Chrome 中的查看源页面上注入(inject)内容脚本。匹配模式将仅匹配一小组有效方案。具体来说,http://https://file://ftp://

A match pattern is essentially a URL that begins with a permitted scheme (http, https, file, or ftp, and that can contain '*' characters. The special pattern matches any URL that starts with a permitted scheme.

此外,匹配页面指定“基本语法”部分中可用的确切值列表。

<scheme> := '*' | 'http' | 'https' | 'file' | 'ftp'

因此,最终您将无法修改查看源页面。

关于javascript - 是否可以从查看源页面上的 Chrome 扩展程序运行内容脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59219381/

相关文章:

javascript - AngularJS 和 JSON - 添加子对象

javascript - jQuery AJAX 不重定向?

javascript - 如果我重定向我的域名,我是否能够向我的旧订阅者发送推送?

google-chrome - WebGL2 支持的显卡

google-chrome - 来自所有已登录设备的浏览器历史记录未进入 chrome 扩展程序

javascript - 在 Cookie 中存储用户偏好

apache - Chrome 开发者工具网络请求报告响应时间过长

html - 制作一个屏幕宽度一定的div元素 "think"?

javascript - 如何使用扩展程序将代码注入(inject) facebook/google 网页?

javascript - 在 Chrome 扩展的 iframe 中使用 Twitter Bootstrap JS