(()=>{"use strict";var e,n={975:function(e,n,s){var t=this&&this.__awaiter||function(e,n,s,t){return new(s||(s=Promise))((function(i,o){function a(e){try{d(t.next(e))}catch(e){o(e)}}function r(e){try{d(t.throw(e))}catch(e){o(e)}}function d(e){var n;e.done?i(e.value):(n=e.value,n instanceof s?n:new s((function(e){e(n)}))).then(a,r)}d((t=t.apply(e,n||[])).next())}))};Object.defineProperty(n,"__esModule",{value:!0});const i=s(913),o=s(593),a=s(699),r=s(386),d=s(854),l=s(829),c=new o.default;class u{constructor(e){this.messageListener=e}sendMessage(e,n,s){this.messageListener?this.messageListener(n,null,s):chrome.tabs.sendMessage(e,n,s)}query(e,n){this.messageListener?n([{url:document.URL,id:-1}]):chrome.tabs.query(e,n)}}function m(e){return t(this,void 0,void 0,(function*(){const n=new u(e);c.localizeHtmlPage(),yield c.wait((()=>null!==i.default.config));const s={};["sponsorblockPopup","sponsorStart","whitelistChannel","unwhitelistChannel","whitelistToggle","whitelistForceCheck","disableSkipping","enableSkipping","toggleSwitch","showNoticeAgain","optionsButton","helpButton","submitTimes","sponsorTimesContributionsContainer","sponsorTimesContributionsDisplay","sponsorTimesViewsContainer","sponsorTimesViewsDisplay","sponsorTimesViewsDisplayEndWord","sponsorTimesOthersTimeSavedDisplay","sponsorTimesOthersTimeSavedEndWord","sponsorTimesSkipsDoneContainer","sponsorTimesSkipsDoneDisplay","sponsorTimesSkipsDoneEndWord","sponsorTimeSavedDisplay","sponsorTimeSavedEndWord","setUsernameContainer","setUsernameButton","setUsernameStatusContainer","setUsernameStatus","setUsername","usernameInput","usernameValue","submitUsername","sbPopupIconCopyUserID","submissionSection","mainControls","loadingIndicator","videoFound","sponsorMessageTimes","refreshSegmentsButton","whitelistButton","sbDonate","sponsorTimesDonateContainer","sbConsiderDonateLink","sbCloseDonate"].forEach((e=>s[e]=document.getElementById(e))),(0,r.showDonationLink)()||(s.sbDonate.style.display="none"),s.sbDonate.addEventListener("click",(()=>i.default.config.donateClicked=i.default.config.donateClicked+1)),s.sponsorStart.addEventListener("click",(function(){n.query({active:!0,currentWindow:!0},(e=>{n.sendMessage(e[0].id,{from:"popup",message:"sponsorStart"},(e=>t(this,void 0,void 0,(function*(){y(e);const n=e=>{const n=i.default.configSyncListeners.indexOf(e);-1!==n&&i.default.configSyncListeners.splice(n,1)},s=()=>{y(e),n(s)};i.default.configSyncListeners.push(s),setTimeout((()=>n(s)),200)}))))}))})),s.whitelistToggle.addEventListener("change",(function(){this.checked?n.query({active:!0,currentWindow:!0},(e=>{n.sendMessage(e[0].id,{message:"getChannelID"},(function(e){if(!e.channelID)return void alert(chrome.i18n.getMessage("channelDataNotFound")+" https://github.com/ajayyy/SponsorBlock/issues/753");let t=i.default.config.whitelistedChannels;null==t&&(t=[]),t.push(e.channelID),s.whitelistChannel.style.display="none",s.unwhitelistChannel.style.display="unset",document.querySelectorAll(".SBWhitelistIcon")[0].classList.add("rotated"),i.default.config.forceChannelCheck||s.whitelistForceCheck.classList.remove("hidden"),i.default.config.whitelistedChannels=t,n.query({active:!0,currentWindow:!0},(e=>{n.sendMessage(e[0].id,{message:"whitelistChange",value:!0})}))}))})):n.query({active:!0,currentWindow:!0},(e=>{n.sendMessage(e[0].id,{message:"getChannelID"},(function(e){let t=i.default.config.whitelistedChannels;null==t&&(t=[]);const o=t.indexOf(e.channelID);t.splice(o,1),s.whitelistChannel.style.display="unset",s.unwhitelistChannel.style.display="none",document.querySelectorAll(".SBWhitelistIcon")[0].classList.remove("rotated"),i.default.config.whitelistedChannels=t,n.query({active:!0,currentWindow:!0},(e=>{n.sendMessage(e[0].id,{message:"whitelistChange",value:!1})}))}))}))})),s.whitelistForceCheck.addEventListener("click",(()=>{chrome.runtime.sendMessage({message:"openConfig",hash:"behavior"})})),s.toggleSwitch.addEventListener("change",(function(){!function(e){i.default.config.disableSkipping=e;let n=s.disableSkipping,t=s.enableSkipping;e||(n=s.enableSkipping,t=s.disableSkipping),t.style.display="unset",n.style.display="none"}(!this.checked)})),s.submitTimes.addEventListener("click",(function(){m.length>0&&n.query({active:!0,currentWindow:!0},(e=>{n.sendMessage(e[0].id,{message:"submitTimes"})}))})),s.showNoticeAgain.addEventListener("click",(function(){i.default.config.dontShowNotice=!1,s.showNoticeAgain.style.display="none"})),s.setUsernameButton.addEventListener("click",T),s.usernameValue.addEventListener("click",T),s.submitUsername.addEventListener("click",(function(){s.setUsernameStatusContainer.style.display="unset",s.setUsernameStatus.innerText=chrome.i18n.getMessage("Loading"),c.sendRequestToServer("POST","/api/setUsername?userID="+i.default.config.userID+"&username="+s.usernameInput.value,(function(e){200==e.status?(s.submitUsername.style.display="none",s.usernameInput.style.display="none",s.setUsernameContainer.style.removeProperty("display"),s.setUsername.classList.remove("SBExpanded"),s.usernameValue.innerText=s.usernameInput.value,s.setUsernameStatusContainer.style.display="none",s.sponsorTimesContributionsContainer.classList.remove("hidden")):s.setUsernameStatus.innerText=l.GenericUtils.getErrorMessage(e.status,e.responseText)})),s.setUsernameContainer.style.display="none",s.setUsername.style.display="unset"})),s.optionsButton.addEventListener("click",(function(){chrome.runtime.sendMessage({message:"openConfig"})})),s.helpButton.addEventListener("click",(function(){chrome.runtime.sendMessage({message:"openHelp"})})),s.refreshSegmentsButton.addEventListener("click",(function(){const e=d.AnimationUtils.applyLoadingAnimation(s.refreshSegmentsButton,.3);n.query({active:!0,currentWindow:!0},(s=>{n.sendMessage(s[0].id,{message:"refreshSegments"},(n=>{f(n),e()}))}))})),s.sbPopupIconCopyUserID.addEventListener("click",(()=>t(this,void 0,void 0,(function*(){return navigator.clipboard.writeText(yield c.getHash(i.default.config.userID))}))));let o=!1,m=[],p=null;const g=i.default.config.disableSkipping;null!=g&&g&&(s.disableSkipping.style.display="none",s.enableSkipping.style.display="unset",s.toggleSwitch.checked=!1);const h=i.default.config.dontShowNotice;function f(e){chrome.runtime.lastError?C():(null!=e&&(s.mainControls.style.display="flex",e.onMobileYouTube&&s.mainControls.classList.add("hidden"),s.whitelistButton.classList.remove("hidden"),s.loadingIndicator.style.display="none",e.found?(s.videoFound.innerHTML=chrome.i18n.getMessage("sponsorFound"),function(e){var s;if(null!=e.sponsorTimes){const t=e.sponsorTimes.sort(((e,n)=>e.segment[1]-n.segment[1])).sort(((e,n)=>e.segment[0]-n.segment[0])),o=document.getElementById("issueReporterTimeButtons");for(;o.firstChild;)o.removeChild(o.firstChild);const r=i.default.config.isVip;for(let e=0;eb(1,l)));const C=document.createElement("img");C.id="sponsorTimesDownvoteButtonsContainer"+l,C.className="voteButton",C.src=u&&r?chrome.runtime.getURL("icons/thumbs_down_locked.svg"):chrome.runtime.getURL("icons/thumbs_down.svg"),C.addEventListener("click",(()=>b(0,l)));const S=document.createElement("img");S.id="sponsorTimesCopyUUIDButtonContainer"+l,S.className="voteButton",S.src=chrome.runtime.getURL("icons/clipboard.svg"),S.addEventListener("click",(()=>{navigator.clipboard.writeText(l),d.AnimationUtils.applyLoadingAnimation(S,.3)()}));const w=document.createElement("img");w.id="sponsorTimesCopyUUIDButtonContainer"+l,w.className="voteButton",t[e].hidden===a.SponsorHideType.Hidden?w.src=chrome.runtime.getURL("icons/not_visible.svg"):w.src=chrome.runtime.getURL("icons/visible.svg"),w.addEventListener("click",(()=>{d.AnimationUtils.applyLoadingAnimation(w,.4)(),t[e].hidden===a.SponsorHideType.Hidden?(w.src=chrome.runtime.getURL("icons/visible.svg"),t[e].hidden=a.SponsorHideType.Visible):(w.src=chrome.runtime.getURL("icons/not_visible.svg"),t[e].hidden=a.SponsorHideType.Hidden),n.query({active:!0,currentWindow:!0},(s=>{n.sendMessage(s[0].id,{message:"hideSegment",type:t[e].hidden,UUID:l})}))})),v.appendChild(T),v.appendChild(C),v.appendChild(S),t[e].actionType===a.ActionType.Skip&&[a.SponsorHideType.Visible,a.SponsorHideType.Hidden].includes(t[e].hidden)&&v.appendChild(w),m.addEventListener("click",(function(){v.classList.toggle("voteButtonsContainer--hide")}));const k=document.createElement("div");k.id="sponsorTimesVoteStatusContainer"+l,k.classList.add("sponsorTimesVoteStatusContainer"),k.style.display="none";const L=document.createElement("div");L.id="sponsorTimesThanksForVotingText"+l,L.classList.add("sponsorTimesThanksForVotingText"),k.appendChild(L),y.append(m),y.append(v),y.append(k),o.appendChild(y)}}}(e)):s.videoFound.innerHTML=chrome.i18n.getMessage("sponsor404")),n.query({active:!0,currentWindow:!0},(e=>{n.sendMessage(e[0].id,{message:"isChannelWhitelisted"},(function(e){e.value&&(s.whitelistChannel.style.display="none",s.unwhitelistChannel.style.display="unset",s.whitelistToggle.checked=!0,document.querySelectorAll(".SBWhitelistIcon")[0].classList.add("rotated"))}))})))}function y(e){o=e.creatingSegment,o||(m=i.default.config.unsubmittedSegments[p]||[]),v()}function v(){s.sponsorStart.innerText=chrome.i18n.getMessage(o?"sponsorEnd":"sponsorStart"),s.submissionSection.style.display=m&&m.length>0?"unset":"none"}function T(){s.usernameInput.value=s.usernameValue.innerText,s.submitUsername.style.display="unset",s.usernameInput.style.display="unset",s.setUsernameContainer.style.display="none",s.setUsername.style.display="flex",s.setUsername.classList.add("SBExpanded"),s.setUsernameStatusContainer.style.display="none",s.sponsorTimesContributionsContainer.classList.add("hidden")}function C(){document.getElementById("loadingIndicator").innerText=chrome.i18n.getMessage("noVideoID")}function S(e,n){document.getElementById("sponsorTimesVoteButtonsContainer"+n).style.display="none",document.getElementById("sponsorTimesVoteStatusContainer"+n).style.removeProperty("display"),document.getElementById("sponsorTimesThanksForVotingText"+n).innerText=e}function b(e,s){S(chrome.i18n.getMessage("Loading"),s),n.query({active:!0,currentWindow:!0},(t=>{n.sendMessage(t[0].id,{message:"submitVote",type:e,UUID:s},(function(e){null!=e&&(1==e.successType||-1==e.successType&&429==e.statusCode?S(chrome.i18n.getMessage("voted"),s):-1==e.successType&&S(l.GenericUtils.getErrorMessage(e.statusCode,e.responseText),s))}))}))}function w(e){e=Math.round(10*e)/10;const n=Math.floor(e/1440),s=Math.floor(e/60)%24;return(n>0?n+chrome.i18n.getMessage("dayAbbreviation")+" ":"")+(s>0?s+chrome.i18n.getMessage("hourAbbreviation")+" ":"")+(e%60).toFixed(1)}null!=h&&h&&(s.showNoticeAgain.style.display="unset"),c.sendRequestToServer("GET","/api/userInfo?value=userName&value=viewCount&value=minutesSaved&userID="+i.default.config.userID,(e=>{if(200===e.status){const n=JSON.parse(e.responseText);s.usernameValue.innerText=n.userName;const t=n.viewCount;0!=t&&(s.sponsorTimesViewsDisplayEndWord.innerText=t>1?chrome.i18n.getMessage("Segments"):chrome.i18n.getMessage("Segment"),s.sponsorTimesViewsDisplay.innerText=t.toLocaleString(),s.sponsorTimesViewsContainer.style.display="unset"),function(e){i.default.config.showDonationLink&&i.default.config.donateClicked<=0&&i.default.config.showPopupDonationCount<5&&e<5e4&&!i.default.config.isVip&&i.default.config.skipCount>10&&(s.sponsorTimesDonateContainer.style.display="flex",s.sbConsiderDonateLink.addEventListener("click",(()=>{i.default.config.donateClicked=i.default.config.donateClicked+1})),s.sbCloseDonate.addEventListener("click",(()=>{s.sponsorTimesDonateContainer.style.display="none",i.default.config.showPopupDonationCount=100})),i.default.config.showPopupDonationCount=i.default.config.showPopupDonationCount+1)}(t);const o=n.minutesSaved;0!=o&&(s.sponsorTimesOthersTimeSavedEndWord.innerText=1!=o?chrome.i18n.getMessage("minsLower"):chrome.i18n.getMessage("minLower"),s.sponsorTimesOthersTimeSavedDisplay.innerText=w(o))}})),null!=i.default.config.sponsorTimesContributed&&(s.sponsorTimesContributionsDisplay.innerText=i.default.config.sponsorTimesContributed.toLocaleString(),s.sponsorTimesContributionsContainer.classList.remove("hidden")),null!=i.default.config.skipCount&&(1!=i.default.config.skipCount?s.sponsorTimesSkipsDoneEndWord.innerText=chrome.i18n.getMessage("Segments"):s.sponsorTimesSkipsDoneEndWord.innerText=chrome.i18n.getMessage("Segment"),s.sponsorTimesSkipsDoneDisplay.innerText=i.default.config.skipCount.toLocaleString(),s.sponsorTimesSkipsDoneContainer.style.display="unset"),null!=i.default.config.minutesSaved&&(1!=i.default.config.minutesSaved?s.sponsorTimeSavedEndWord.innerText=chrome.i18n.getMessage("minsLower"):s.sponsorTimeSavedEndWord.innerText=chrome.i18n.getMessage("minLower"),s.sponsorTimeSavedDisplay.innerText=w(i.default.config.minutesSaved)),setTimeout((()=>s.sponsorblockPopup.classList.remove("preload")),250),n.query({active:!0,currentWindow:!0},(e=>function(e,s){n.sendMessage(e[0].id,{message:"getVideoID"},(function(s){void 0!==s&&s.videoID?(p=s.videoID,o=s.creatingSegment,function(e,s){var t;p?(m=null!==(t=i.default.config.unsubmittedSegments[p])&&void 0!==t?t:[],v(),n.sendMessage(e[0].id,{message:"isInfoFound",updating:false},f)):C()}(e)):void 0===s&&chrome.runtime.lastError&&C()}))}(e)))}))}null!=chrome.tabs&&m(),n.default=m}},s={};function t(e){var i=s[e];if(void 0!==i)return i.exports;var o=s[e]={exports:{}};return n[e].call(o.exports,o,o.exports,t),o.exports}t.m=n,e=[],t.O=(n,s,i,o)=>{if(!s){var a=1/0;for(c=0;c=o)&&Object.keys(t.O).every((e=>t.O[e](s[d])))?s.splice(d--,1):(r=!1,o0&&e[c-1][2]>o;c--)e[c]=e[c-1];e[c]=[s,i,o]},t.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),(()=>{var e={42:0};t.O.j=n=>0===e[n];var n=(n,s)=>{var i,o,[a,r,d]=s,l=0;if(a.some((n=>0!==e[n]))){for(i in r)t.o(r,i)&&(t.m[i]=r[i]);if(d)var c=d(t)}for(n&&n(s);lt(975)));i=t.O(i)})();