Chrome Extension which is supposed to run on all Facebook pages only runs when I hit refresh

后端 未结 3 812
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-18 14:54

This is my first hack at writing a Chrome extension. I want it to execute some pretty simple JavaScript every time a Facebook page loads. It\'s doing everything I want

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-18 15:19

    I think you might have written your code inside $(function () {}) which obviously require a page load. But you want to run your code if the page DOM changes, then this may help:

    document.addEventListener('DOMNodeInserted', function (event) {
    
    });
    

    More info: http://reminiscential.wordpress.com/2011/10/04/building_google_reader_plugin/

提交回复
热议问题