diff options
Diffstat (limited to 'popup.js')
| -rw-r--r-- | popup.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/popup.js b/popup.js new file mode 100644 index 0000000..21cfed4 --- /dev/null +++ b/popup.js @@ -0,0 +1,22 @@ +document.getElementById('activate').addEventListener('click', () => { + browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => { + if (tabs[0].url.includes('youtube.com/watch')) { + browser.scripting.executeScript({ + target: { tabId: tabs[0].id }, + files: ['content-script.js'] + }); + } else { + alert("Please open a YouTube video to use the Timestamp Tool."); + } + }); +}); + +document.getElementById('offset').addEventListener('input', () => { + const offset = parseInt(document.getElementById('offset').value, 10); + browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => { + browser.tabs.sendMessage(tabs[0].id, { type: 'SET_OFFSET', offset: offset }); + localStorage.setItem('offset', offset); + }); +}); + +localStorage.getItem('offset') !== null ? document.getElementById('offset').value = localStorage.getItem('offset') : document.getElementById('offset').value = 5;
\ No newline at end of file |
