aboutsummaryrefslogtreecommitdiffstats
path: root/popup.js
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2024-10-08 01:04:31 -0700
committerPinapelz <yukais@pinapelz.com>2024-10-08 01:04:31 -0700
commitdb48ff702b1496362eeebe58955d85adf6a36361 (patch)
treea126bd0e7fb51008f67155387b6970d7d71e4cf1 /popup.js
Initial commit
Diffstat (limited to 'popup.js')
-rw-r--r--popup.js22
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
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage