WebExtension查找语句

时间:2018-12-07 09:05:48

标签: javascript firefox firefox-addon firefox-webextensions

我是WebExtension编程的新手。在完成一些在线教程之后,我决定继续使用自己的小程序,当相应页面包含特定字词(browser.find.find(“ word”))时,该程序应仅将边框添加到我的标签中。 允许“查找”。不幸的是,它不起作用。在调试期间,该脚本在内容脚本中的“ find”语句处停止(由console.log语句检查)。

//Manifest.json:{
"manifest_version": 2,
"name": "webextension-example",
"version": "0.1",
"description": "An example.",

"content_scripts": [
    {
        "matches": ["<all_urls>"],
        "js": ["borderify.js"]
    }
],
"permissions": [
    "notifications",
    "webNavigation",
    "activeTab",
    "tabs",
    "find"
]}

还有content_script:

function found(results) {
   if (results.count > 0) {
     console.log(`found at least one word (isn't triggered as well)`);
     browser.find.highlightResults();
     document.body.style.border = "50px solid red";
  }
}
console.log(`Checkpoint stil gets triggered`);
//>>> This is where I don't get any response
browser.find.find("and").then(found);
console.log(`Checkpoint doesn't get triggered`);

0 个答案:

没有答案