Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/401.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 有没有一种方法可以将所有html代码替换为带有chrome扩展的修改版本_Javascript_Html_Google Chrome Extension - Fatal编程技术网

Javascript 有没有一种方法可以将所有html代码替换为带有chrome扩展的修改版本

Javascript 有没有一种方法可以将所有html代码替换为带有chrome扩展的修改版本,javascript,html,google-chrome-extension,Javascript,Html,Google Chrome Extension,我正在制作一个google chrome扩展,当你访问某个网站时,它会替换网站上脚本标签下的一些代码。我已经有manifest.json文件在您访问指定网站时触发content\u脚本,但我需要知道如何用新代码替换整个网站的html代码。我曾考虑过使用document.write,但无法使其正常工作。document.body.innerHTML='hello'。 这将替换的所有内容,谢谢,但我有一个问题,您能否将document.body.innerHTML替换为for ex.document

我正在制作一个google chrome扩展,当你访问某个网站时,它会替换网站上
脚本
标签下的一些代码。我已经有manifest.json文件在您访问指定网站时触发
content\u脚本
,但我需要知道如何用新代码替换整个网站的html代码。我曾考虑过使用
document.write
,但无法使其正常工作。

document.body.innerHTML='hello'

这将替换

的所有内容,谢谢,但我有一个问题,您能否将document.body.innerHTML替换为for ex.document.head.innerHTML