chrome拡張機能で新しい タブを 拡張機能のapi使って開かせるところまではできたのですがその新しく開かれたタブのwindowオブジェクトを操作できなくて困っております。
function searchBooks(info, tab) { console.log("AAA") var query = info.selectionText; chrome.tabs.create({ selected: true, url: 'https://opac.jp/opac/opac_search.cgi?smode=1' }); chrome.tabs.onUpdated.addListener(function addString(query) { console.log(window.document) document.getElementById("text_kywd1").innerText = "fuck" console.log(query, "am i called") }) }
chrome.tabs.onUpdated.addListenerでtabが開かれたあと呼ばれる関数を定義しました。
console.log(window.document)の出力結果を見てみると出力されたのは拡張機能自体のhtmlでした。
どのようにしたら新たに開かれたタブを操作できるのでしょうか。
manifesut.json
```
{
"update_url": "https://clients2.google.com/service/update2/crx",
"name": "Viewer",
"manifest_version": 2,
"description": "Search books throughipac.",
"version": "1.5.6",
"permissions": [
"contextMenus"
],
"icons": {
"16": "icon16.png",
"48": "icon48.png",
"128": "icon128.png"
},
"background": {
"page": "rightClickSearch.html"
},
"browser_action": {
"default_icon": "icon16.png"
},
"content_security_policy": "script-src 'self' https://ssl.google-analytics.com; object-src 'self'"
}
background.jsには何も書いておりませんでした。
回答1件
あなたの回答
tips
プレビュー