开发者

Controlling tabs in a Chrome extension

开发者 https://www.devze.com 2023-01-19 07:55 出处:网络
I am new to the world of creating Chrome extensions.My extension will not require any type of UI.I would like the extension to run in the background and take note whenever a new tab is created and whe

I am new to the world of creating Chrome extensions. My extension will not require any type of UI. I would like the extension to run in the background and take note whenever a new tab is created and when a tab is closed. Later on I'd like the extension to do other things but I'll be happy with just receiving tab "close" and tab "open" notifications.

Any poin开发者_运维技巧ters as to where I should start?

Thank you so much! Matty P


You can start with reading about background pages and Tabs API that allows you to catch those events.


you can detect this using:

chrome.tabs.onCreated.addListener(function(Tab tab) {...});

Parameters

tab( Tab ) Details of the tab that was created.

and

chrome.tabs.onRemoved.addListener(function(integer tabId, object removeInfo) {...});

Parameters tabId ( integer ) removeInfo ( object ) isWindowClosing ( boolean ) True when the tab is being closed because its window is being closed.

Detail at http://code.google.com/chrome/extensions/tabs.html

0

精彩评论

暂无评论...
验证码 换一张
取 消