since my Chrome Extension didn’t work under Mac I broke the code down and found the problem:
background.js
chrome.browserAction.onClicked.addListener(function(tab){
alert("Goin to");
chrome.tabs.executeScript(tab.id, {file: "script.js"});
});
script.js
$('#Hoster_30').trigger('click');
alert("Clicked");
jQuery is loaded and both alerts are shown, but the click event isn’t triggered. It works fine when I directly enter the trigger in the js console on the page and under Windows it also works in the add on.
Here my manifest.json
{
"name": "MacAddon",
"version": "0.1",
"permissions": ["tabs", "http://*/", "https://*/"],
"background": {
"scripts": ["background.js"]
},
"browser_action": {
"default_title": "MacAddon"
},
"content_scripts": [
{
"matches": ["http://*.kinox.to/*", "http://*.streamcloud.eu/*"],
"js": ["jquery.js"]
}
]
}
For Chrome 19-, you have to inject the code and use the website’s own method to switch the Episode.
(To find out which function had to be called, I inspected the
$().data('events')object in the console:$('#Hoster_30').data('events').click[0].handler).In Chrome 20+, using
.trigger('click')from the content script worked fine:Thanks Rob W. for welcoming me so greatly here and answering the Question!