J
J
josser2012-12-10 21:12:25
JavaScript
josser, 2012-12-10 21:12:25

Uploading scripts to the site in the Google Chrome extension

It would seem that nothing complicated, but no.
I want a small addition for vk.com.

I add to manifest.json:

"content_scripts": [
   {
     "matches": ["http://vk.com/friends"],
     "js": ["js/lib/jquery.min.js", "js/friends.js"],      
   },
 ]


In the script while the usual alert ()

If you just load the page / friends alert () works.
But if you click on the link, for example, "News", and then go back to "Friends", then everything no longer works out.
I think this is due to the fact that vk uses history.pushState ()
But how then to be?
I want to add one more menu item for each user, in addition to the standard ones. Naturally, I need to do this on every page load, but I would not want to do this on all vk pages.
Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evengard, 2012-12-10
@Evengard

Actually, you have to. There is no de facto page change, so matches is not executed. So you have to embed the script on all contact pages, and already from it to detect which particular page is open

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question