From 9b6bd4a85fd17f1f5a376417052b3b428fca1887 Mon Sep 17 00:00:00 2001 From: rohan Date: Mon, 7 Jun 2021 19:08:30 +0530 Subject: [PATCH] choose "selected" by default if multiple tabs are selected when popup is opened --- scripts/popup.js | 8 +++----- scripts/track.js | 1 + 2 files changed, 4 insertions(+), 5 deletions(-) create mode 100644 scripts/track.js diff --git a/scripts/popup.js b/scripts/popup.js index 3f5ecfd..7a5d042 100644 --- a/scripts/popup.js +++ b/scripts/popup.js @@ -86,14 +86,12 @@ async function buildTargets() { // hide groups if not chrome if (getBrowser() !== 'chrome' || true) document.getElementById('group').style.display = 'none'; - if (isActiveTabValid) { + if (isSelectionValid) { + document.getElementById('selection').classList.add('active'); + } else if (isActiveTabValid) { document.getElementById('tab').classList.add('active'); } else if (isWindowValid) { document.getElementById('window').classList.add('active'); - } else if (isSelectionValid) { - document.getElementById('selection').classList.add('active'); - // } else if (isGroupValid) { - // document.getElementById('group').classList.add('active'); } else { document.querySelectorAll('.choice, .custom-choice, h3').forEach(c => {c.classList.add('disabled');c.setAttribute('tabindex','-1')}); return document.getElementById('preview-text').innerText = `Can't snooze this tab`; diff --git a/scripts/track.js b/scripts/track.js new file mode 100644 index 0000000..b4145da --- /dev/null +++ b/scripts/track.js @@ -0,0 +1 @@ +(e=>{const{location:{hostname:t,pathname:n,search:s},document:a}=e,i=a.querySelector("script[data-website-id]"),o=e=>i&&i.getAttribute(e),c=o("data-website-id"),l=o("data-host-url"),r=l?(p=l)&&p.length>1&&p.endsWith("/")?p.slice(0,-1):p:i.src.split("/").slice(0,-1).join("/");var p;let d=`${n}${s}`;const u=(e,n,s)=>{const a={website:s,hostname:t};n&&Object.keys(n).forEach((e=>{a[e]=n[e]})),((e,t)=>{const n=new XMLHttpRequest;n.open("POST",e,!0),n.setRequestHeader("Content-Type","application/json"),n.send(JSON.stringify(t))})(`${r}/api/collect`,{type:e,payload:a})},m=(e,t="custom",n=d,s=c)=>u("event",{event_type:t,event_value:e,url:n},s);if(!e.umami){const t=e=>m(e);t.trackEvent=m,e.umami=t}})(window); \ No newline at end of file