manifest.json
Код: Выделить всё
{
"manifest_version": 2,
"name": "Check'em All",
"description": "",
"version": "1.0",
"browser_action": {
"default_popup": "popup.html"
},
"background": {
"persistent": true,
"scripts": ["jquery.js", "background.js"]
},
"content_scripts": [{
"matches": ["file:///*"],
"js" : ["popup.js"]
}],
"permissions": [
"tabs",
"http://*/*",
"https://*/*"
]
}
< /code>
[b] popup.html[/b]
Check'em All!
Check'em All!
BUTTON
< /code>
[b] popup.js[/b]
document.addEventListener('DOMContentLoaded', function () {
var btn = document.getElementById('check-btn');
btn.addEventListener('click', injectScript);
});
function injectScript() {
alert('Handler called!');
chrome.tabs.executeScript(null, { file: 'background.js' });
}
< /code>
[b] background.js[/b]
$(document).ready(function(){
$('.star_gray').click();
$('a.btn.page_next').click();
});
< /code>
С кодом выше, когда я нажимаю кнопку (#check-btnПодробнее здесь: https://stackoverflow.com/questions/345 ... -extension