【发布时间】:2021-12-10 05:49:24
【问题描述】:
我经常在学习时阅读 youtube cmets 来浪费时间。所以我有了一个想法,决定做一个扩展来隐藏 cmets 部分。我找到了元素的 ID,做了一个简单的扩展,但它没有工作,导致以下错误:
我的扩展的 html 文件:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Comminator | Youtube Comment Terminator</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<button id="main" onclick="hide()">Terminate</button>
<script type="text/javascript">
var comments = document.getElementById("comments"); //"comments" is the ID of comments section in youtube
function hide() {
comments.style.display = "none";
}
</script>
</body>
</html>
{
"manifest_version": 2,
"name": "Comminator",
"description": "Youtube Comment Hider",
"version": "1.0",
"icons": {"128": "icon_128.png"},
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"permissions": ["activeTab"]
}
我们不能干扰元素吗? chrome不允许吗?
【问题讨论】:
标签: javascript html dom google-chrome-extension