Answer the question
In order to leave comments, you need to log in
When you navigate to another page, does the chrome extension stop working?
I'm making an extension for chrome, which adds another button to the "Attach" tab when writing a VK post.
Here is my manifest:
{
"manifest_version": 2,
"name": "Chrome extension",
"version": "0.1",
"icons": {
"128": "128x128.png"
},
"permissions": [
"tabs",
"http://vk.com/*",
"https://vk.com/*"
],
"content_scripts": [
{
"all_frames": true,
"matches": ["http://vk.com/*","https://vk.com/*"],
"css": ["style.css"],
"js": ["jquery.js","script.js"],
"run_at": "document_start"
}],
"web_accessible_resources": [ "img.png" ]
}
window.onload = function(){
$( ".add_media_type_1_audio" ).after( "<a class='add_media_type_26_audio add_media_item activate_modal' name='code_window' style='background-image: url("+chrome.extension.getURL('img.png')+"); background-position: 3px 3px;'><nobr>Кнопка</nobr></a>" );
// тут остальные действия с этой кнопкой
}
Answer the question
In order to leave comments, you need to log in
window.onload will only fire after the page is loaded. VK page changes through ajax and history api.
Use
https://github.com/kapetan/jquery-observe or https://github.com/megawac/MutationObserver.js or https://github.com/Polymer/MutationObservers
Some of them were buggy, but no longer remember which one. Unsubscribe later, which of this is working.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question