How to detect page title change in Google Chrome from an extension?

后端 未结 4 674
南笙
南笙 2020-12-28 09:44

I\'m creating a Google Chrome extension and I need to detect when a page\'s title changes. The page\'s title is changed like in Twitter: (num) Twitter (see the

4条回答
  •  误落风尘
    2020-12-28 10:30

    1. Create an event page.

    2. Create a content script that gets injected into a webpage when a webpage loads.

    3. Within the content script, use setInterval to poll the page to see if window.document.title changes.

    4. If the title has changed, use chrome.runtime.sendMessage to send a message to your event page.

    5. On your event page, listen for messages with chrome.runtime.onMessage and play a sound.

提交回复
热议问题