Tìm kiếm hỗ trợ

Tránh các lừa đảo về hỗ trợ. Chúng tôi sẽ không bao giờ yêu cầu bạn gọi hoặc nhắn tin đến số điện thoại hoặc chia sẻ thông tin cá nhân. Vui lòng báo cáo hoạt động đáng ngờ bằng cách sử dụng tùy chọn "Báo cáo lạm dụng".

Learn More

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

  • 3 trả lời
  • 1 gặp vấn đề này
  • 180 lượt xem
  • Trả lời mới nhất được viết bởi 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.

Giải pháp được chọn

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.

Đọc câu trả lời này trong ngữ cảnh 👍 1

Tất cả các câu trả lời (3)

more options

Giải pháp được chọn

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.

Được chỉnh sửa bởi specialx1 vào

more options

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

2)