我對鉻擴展開發完全陌生。 我試圖改變DOM(追加數據到活動網頁)當點擊一個按鈕在擴展彈出。這怎麼可能。Chrome擴展程序用擴展彈出式按鈕改變DOM
清單文件
{
"manifest_version": 2,
"name": "test 2",
"description": "test ext 2",
"version": "1.0",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"content_scripts": [
{
"matches": ["http://*/*","https://*/*"],
"js": ["jquery.min.js", "main.js"]
}
],
"permissions": [
"activeTab"
]
}
假設如果popup.html文件
<!doctype html>
<html>
<head>
<title>test extension 2</title>
<script src="popup.js"></script>
</head>
<body>
<a id="button">button</a>
</body>
</html>
,當我在#鍵點擊,我想執行的main.js文件中的一些jQuery的代碼會將一些數據附加到活動網頁。
謝謝。
的可能的複製[Chrome擴展 - 消息從彈出傳遞到內容腳本](http://stackoverflow.com/問題/ 6108906/chrome-extension-message-passing-from-popup-to-content-script) –
@HaibaraAi如果我的問題被這樣的重複封閉,我不知道該怎麼做。這只是解決方案的一小部分。 – Xan
感謝您提供的鏈接。它有助於獲得一個想法,但現在我正在尋找在popup.html中加入一個按鈕,並添加一個將更改活動頁面的DOM的偵聽器。我正在尋找這樣的東西,[鏈接](http://stackoverflow.com/questions/11996053/detect-a-button-click-in-the-browser-action-form-of-a-google-chrome-擴展名) –