搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

Learn More

How to run JS code through extension at about:home page?

  • 3 回覆
  • 1 有這個問題
  • 179 次檢視
  • 最近回覆由 cor-el

more options

I tried:

"content_scripts": [

       {
           "matches": [
               "about:home" 
           ],
           "js": [
               "main.js"
           ]
       }

But it doesn't work. And about:newtab also doesn't work

I know that I can do chrome_url_overrides, to replace newtab with my own page, but I really wanted to run my JS code on existing inbuilt homepage.

I know that I can run my own CSS via userContent.css, but how do I run my own JS?

Can I even run scripts at about:newtab? Maybe its not supported through api, since https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Match_patterns doesn't show any example of accessing it. If so, where is about:newtab HTML file located? Maybe I could inject my code through file, without making extesion.

I tried: "content_scripts": [ { "matches": [ "about:home" ], "js": [ "main.js" ] } But it doesn't work. And about:newtab also doesn't work I know that I can do chrome_url_overrides, to replace newtab with my own page, but I really wanted to run my JS code on existing inbuilt homepage. I know that I can run my own CSS via userContent.css, but how do I run my own JS? Can I even run scripts at about:newtab? Maybe its not supported through api, since https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Match_patterns doesn't show any example of accessing it. If so, where is about:newtab HTML file located? Maybe I could inject my code through file, without making extesion.

被選擇的解決方法

That is not possible, extensions do not work on about pages and other special pages and on Mozilla websites and some others and can't inject files.

A JavaScript bookmarklet probably works just like running code in the Web Console.

從原來的回覆中察看解決方案 👍 1

所有回覆 (3)

more options

選擇的解決方法

That is not possible, extensions do not work on about pages and other special pages and on Mozilla websites and some others and can't inject files.

A JavaScript bookmarklet probably works just like running code in the Web Console.

more options

cor-el said

That is not possible, extensions do not work on about pages and other special pages and on Mozilla websites and some others and can't inject files. A JavaScript bookmarklet probably works just like running code in the Web Console.

Firstly, thanks for that quick response, it really clarified things for me. So code in this (https://support.mozilla.org/en-US/questions/1316166) question also won't work because of that.

I have two more questions before I mark this as solved. 1. Where HTML file of about:home is located? I was looking through mozilla files but couldn't find it. Is it compilled to some .dll file or something like that? 2. Where in firefox documentation I can find that extensions do not work on about pages and other special pages and on Mozilla websites and some others? It's not that I doubt your answer, it's just it would be helpful for me to know where to look for those informations.

由 specialx1 於 修改

more options

1) The about:home and about:newtab pages are generated via JavaScript, so there is no real (x)html file.

2)