Mozilla Monitor website will be down for 2 hours starting 5/20/2025 at 6 AM PT. Visit our status site for updates.

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

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

  • 3 replies
  • 1 has this problem
  • 136 views
  • Last reply by cor-el

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.

Chosen solution

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.

Read this answer in context 👍 1

All Replies (3)

Chosen Solution

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.

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.

Modified by specialx1

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

2)