Answer the question
In order to leave comments, you need to log in
How to pause/resume execution of js extension script?
Good afternoon
Tell me how to implement off / on script execution in the active tab.
It is desirable that without additional. windows. Those. clicked on the extension icon - it's on. Pressed again - it is off
Unfortunately, we could not find similar topics. Please help:
Scheme of work:
The page is loaded The
script is loaded
If the extension is on, then the script is executed (
If the extension is off, the script is not executed (if the user is on, then the page should reload and the script should be executed)
I think the meaning is clear? Similar to pausing and resuming adblock
my manifest:
{
"manifest_version": 2,
"name": "Приложение",
"description": "Позволяет облегчить некоторую работу.",
"version": "2.0",
"offline_enabled": true,
"commands": {
"toggle-feature-foo": {
"suggested_key": {
"default": "Ctrl+Shift+Z",
"mac": "Command+Shift+Z"
},
"description": "Toggle feature foo",
"global": true
},
"_execute_browser_action": {
"suggested_key": {
"windows": "Ctrl+Shift+Z",
"mac": "Command+Shift+Z",
"chromeos": "Ctrl+Shift+U",
"linux": "Ctrl+Shift+J"
}
},
"_execute_page_action": {
"suggested_key": {
"default": "Ctrl+Shift+E",
"windows": "Alt+Shift+P",
"mac": "Alt+Shift+P"
}
}
},
"icons": {
"128": "icok.png"
},
"content_scripts": [{
"matches": [
"http://mi.url.ru/*"
],
"js": [
"jquery.js",
"background.js",
"injected.js"
],
"run_at": "document_end"
}],
"permissions": [
"activeTab"
],
"browser_action": {
"default_icon": {
"128": "icok.png"
},
"default_title": "Exten$ion"
},
"web_accessible_resources": [
"/injected.js"
]
}
$.get(chrome.extension.getURL('/injected.js'),
function(data) {
var script = document.createElement("script");
script.setAttribute("type", "text/javascript");
script.innerHTML = data;
document.getElementsByTagName("head")[0].appendChild(script);
document.getElementsByTagName("body")[0].setAttribute("onLoad", "injected_main();");
});
$(document).ready(function() {
//Тут какие - то действия
...
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question