我已经构建了一个简单的应用来修改用户在使用Adwords时输入到文本区域的单词。但是,当我尝试加载解压缩的扩展时,javascript文件表示加载它时出错。
这是我的清单:
{
"name": "Keyword Modifier",
"version": "1.0",
"manifest_version": 2,
"description": "Just copy/paste your keywords and modify them in bulk.",
"icons": {
"16": "icons/icon16.png",
"48": "icons/icon48.png",
"128": "icons/icon128.png"
},
"default_locale": "en",
"browser_action": {
"default_icon": "icons/icon19.png",
"default_title": "Keyword Modifier",
"default_popup": "src/browser_action/browser_action.html"
},
"content_scripts": [
{
"matches": [
"https://www.google.com/*"
],
"js": [
"js/popup.js"
]
}
]
}

这是javascript:
var keywordBox = document.getElementById('keywordBox');
var phraseButton = document.getElementById('phraseButton');
var exactButton = document.getElementById('exactButton');
var modifiedButton = document.getElementById('modifiedButton');
phraseButton.addEventListener('click', function() {
keywordBox.value = ('"' + keywordBox.value + '"');
keywordBox.value = keywordBox.value.replace(/\n/g, '"\n"');
});
exactButton.addEventListener('click', function () {
keywordBox.value = ('[' + keywordBox.value + ']');
keywordBox.value = keywordBox.value.replace(/\n/g, ']\n[');
});
modifiedButton.addEventListener('click', function () {
keywordBox.value = keywordBox.value.replace(/^/gm, "+")
keywordBox.value = keywordBox.value.replace(/ /g, ' +')
});

我已经在Glitch上对此进行了测试,并且知道我的程序正常工作,所以我很好奇可能导致错误的原因。谢谢你的帮助!
答案 0 :(得分:0)
结帐你的项目:
"default_popup": "src/browser_action/browser_action.html"
根/ SRC / browser_action / browser_action.html
"js": [
"js/popup.js"
]
根/ JS / popup.js
browser_action.html
html-code <script src="../../js/popup.js"></script>