• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1function setTitle(title) {
2    chrome.tabs.executeScript({
3        code: 'document.title = "' + title + '"'
4    });
5}
6
7chrome.commands.onCommand.addListener((command) => {
8    if (command === 'activeTab') {
9        chrome.tabs.query({active: true, currentWindow: true}, (tabs) => {
10            chrome.tabs.sendMessage(tabs[0].id, {text: 'title'}, (method) => {
11                if (method === 'captureVisibleTab') {
12                    chrome.tabs.captureVisibleTab((img) => {
13                        setTitle(img);
14                    });
15                } else if (method === 'tabCapture') {
16                    chrome.tabCapture.capture({video: true}, (stream) => {
17                        setTitle(stream);
18                    });
19                } else if (method === 'desktopCapture') {
20                    chrome.desktopCapture.chooseDesktopMedia(
21                        ['screen', 'window', 'tab'], (streamId) => {
22                            setTitle(streamId);
23                        }
24                    );
25                }
26            });
27        });
28    }
29});
30