Updated
Thanks @kofifus for the info, Chrome as of 61 explicitly forbids content scripts on its default new tab page
Previous
Say I have the following sample extension, it will output test
in console.
manifest.json
{
"name": "Test",
"version": "1.0",
"manifest_version": 2,
"content_scripts": [
{
"matches": [
"<all_urls>"
],
"js": [
"content.js"
]
}
]
}
content.js
console.log('test');
Will above extension work well in chrome://newtab
page?
Some helpful info:
I know by default chrome extension can't access to chrome://
pages, and we could change this behavior through chrome://flags/#extensions-on-chrome-urls
chrome://newtab
in fact is a url like https://www.google.co.jp/_/chrome/newtab?espv=2&ie=UTF-8
, so it shouldn't be blocked by above restriction.
There are many mouse gestures extension available, like crxMouse, they work well on chrome://newtab
page
There are also some voices saying it's not allowed to inject content scripts in chrome://newtab
, for example, @Xan's comments below this answer
and this author's case
![enter image description here](https://i.stack.imgur.com/muJy7.png)
So it looks weird as its different behavior across different devices( or settings?). Is there any official statements about whether content scripts can run in chrome://newtab
pages? Or is there a setting we could change this behavior?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…