所以我一直在制作我的第一个chrome扩展程序。当行中的<tr>
没有包含按钮上的单词时,它应该删除某个<td>
。我得到的错误是:
未捕获的ReferenceError:$未定义 在chrome-extension://.../scripts/popup.js:2 (匿名)@ chrome-extension://.../scripts/popup.js:2
我不确定我做错了什么,如果这是我在这里犯的唯一错误。任何人都可以解释我做错了什么,并且可能在我的路上帮助我一点代码。
popup.html:
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Popup with search</title>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js">
</script>
<link rel="manifest.json" href="manifest.json">
<script src="popup.js"></script>
</head>
<body>
<h3>Remove all rows which don't contain:</h3>
<div class="container">
<div class="Type">
<h3>Types:</h3>
<button id="PRICAT">PRICAT</button>
</div>
<div class="Format">
<h3>Formats:</h3>
<button id="RetailConnect">RetailConnect</button>
</div>
</div>
的manifest.json:
{
"manifest_version": 2,
"name": "CE QuickSearch ",
"version": "0.1",
"browser_action": {
"default_popup": "popup.html",
"default_title": "Popup with search"
},
"description": "Made by me",
"content_scripts": [
{
"matches": [ "https://url_i_use_it_on/*" ],
"all_frames": true,
"js": [ "scripts/content.js", "scripts/popup.js"]
}
],
"permissions": [
"https://url_i_use_it_on/Message"
],
"content_security_policy": "script-src 'self'
https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js; object-src
'self'"
}
Popup.js:
$("#PRICAT").click(function PRICAT() {
var searchString = $(this).text();
$("#tbody tr td:contains('" + searchString + "')").closest('tr').remove();
});
$("#RetailConnect").click(function RetailConnect() {
var searchString = $(this).text();
$("#tbody tr td:contains('" + searchString + "')").closest('tr').remove();
});
content.js:
console.log("CE QuickSearch is activated..");