Chrome扩展需要Javascript才能从
chrome.tabs.executeScript(null, { code: "js code here" });
用ID做jQuery查找也可以
chrome.tabs.executeScript(null, { code: "$('#testid').val('help me')" });
但是,如果需要按名称查找,Is如何结构化引号apostrophes?
$('[name="testname"]').val('please')
在executeScript函数中插入引号时,我不知道该如何处理引号。似乎我需要一个三撇号。
将引号去掉。
chrome.tabs.executeScript(null, { code: "$('[name=\"testname\"]').val('please')" });
或者使用模板字元(使用反引号)。
chrome.tabs.executeScript(null, { code: `$('[name="testname"]').val('please')` });