Answer the question
In order to leave comments, you need to log in
How to implement an extension for Chrome?
I'm making a Chrome extension for VK.
Here is the manifest:
{
"browser_action": {
"default_icon": "48.png"
},
"content_scripts": [ {
"include_globs": [ "http://vk.com/*", "https://vk.com/*" ],
"js": [ "mainscript.js" ],
"matches": [ "http://*/*", "https://*/*" ],
"run_at": "document_idle"
} ],
"converted_from_user_script": true,
"icons": {
"128": "128.png",
"48": "48.png"
},
"manifest_version": 2,
"name": "Расширялочка",
"update_url": "https://clients2.google.com/service/update2/crx",
"version": "1.0"
}
setTimeout(check_user_page(), 5000)
function check_user_page(){
var profile=document.getElementById('profile_short');
if(!profile) return false;
var page_prison_user_info=document.getElementById('page_user_info');
if(page_user_info) return false;
alert("мы у юзверя!!!");
}
Answer the question
In order to leave comments, you need to log in
you can use DOM MutationObserver.
hang a handler for adding / changing / deleting #profile_short or #page_user_info and the browser will notify you about changes in these elements when they occur (they will be loaded by Ajax and added to the DOM, for example)
you can read it even easier here
- track url changes, it will help with this onhashchange event
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question