How can I run JS code from a google chrome theme

安稳与你 提交于 2019-12-10 21:15:55

问题


Google Chrome themes are defined on the Chrome developer docs as follows:

A theme is a special kind of extension that changes the way the browser looks. Themes are packaged like regular extensions, but they don't contain JavaScript or HTML code.

(emphasis my own)

However I would like to apply some kind of theme which does run JavaScript on the page I load. How can I do this? I have tried adding

"permissions": ["<all_urls>"],
"content_scripts": [
    {
    "matches": [
        "http://*/*",
        "https://*/*"
        ],
    "js": ["content.js"],
    "run_at": "document_end"         // pay attention to this line
    }
],

to my manifest.json and putting the content.js file below in the same .crx package as my manifest as per this answer

(function(window, chrome){
  "use strict";
  var doc = window.document;
  doc.getElementById("mv-tiles").style.opacity = "0";
}(window, chrome));

but the code just doesn't run. Are there any workarounds?

来源:https://stackoverflow.com/questions/43848953/how-can-i-run-js-code-from-a-google-chrome-theme

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!