diff options
author | Ajay Ramachandran <[email protected]> | 2020-05-17 00:00:08 -0400 |
---|---|---|
committer | GitHub <[email protected]> | 2020-05-17 00:00:08 -0400 |
commit | 45d20574d9524e77171fe94dcf00891cd5c30a62 (patch) | |
tree | 0730371aba6be8f8be9e21c830036513e7cf8889 | |
parent | c011ad105d7e2694a1be47e83b5ec4918413a215 (diff) | |
parent | 252da8c56afea294ca2f49585b2353c52fa86611 (diff) | |
download | SponsorBlock-45d20574d9524e77171fe94dcf00891cd5c30a62.tar.gz SponsorBlock-45d20574d9524e77171fe94dcf00891cd5c30a62.zip |
Merge pull request #356 from ajayyy/react1.2.28.4
Fix preview sponsors not skipping
-rw-r--r-- | .github/workflows/release.yml | 25 | ||||
-rw-r--r-- | manifest/manifest.json | 2 | ||||
-rw-r--r-- | public/_locales/en/messages.json | 14 | ||||
-rw-r--r-- | src/components/NoticeComponent.tsx | 33 | ||||
-rw-r--r-- | src/components/SkipNoticeComponent.tsx | 17 | ||||
-rw-r--r-- | src/content.ts | 2 |
6 files changed, 55 insertions, 38 deletions
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e902a81d..50ec9d43 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,9 +18,6 @@ jobs: - name: Copy configuration run: cp config.json.example config.json - - name: Install Zip - run: sudo apt-get install zip - # Create Chrome artifacts - name: Create Chrome artifacts run: npm run build:chrome @@ -30,9 +27,7 @@ jobs: path: dist - run: mkdir ./builds - name: Zip Artifacts - run: cd ./dist - - run: zip -r ../builds/ChromeExtension.zip * - - run: cd ../ + run: cd ./dist ; zip -r ../builds/ChromeExtension.zip * # Create Firefox artifacts - name: Create Firefox artifacts @@ -42,11 +37,7 @@ jobs: name: FirefoxExtension path: dist - name: Zip Artifacts - run: cd ./dist - - uses: montudor/[email protected] - with: - args: zip -r ../builds/FirefoxExtension.zip * - - run: cd ../ + run: cd ./dist ; zip -r ../builds/FirefoxExtension.zip * # Create Beta artifacts (Builds with the name changed to beta) - name: Create Chrome Beta artifacts @@ -56,9 +47,7 @@ jobs: name: ChromeExtensionBeta path: dist - name: Zip Artifacts - run: cd ./dist - - run: zip -r ../builds/ChromeExtensionBeta.zip * - - run: cd ../ + run: cd ./dist ; zip -r ../builds/ChromeExtensionBeta.zip * - name: Create Firefox Beta artifacts run: npm run build:firefox -- --env.stream=beta @@ -67,9 +56,7 @@ jobs: name: FirefoxExtensionBeta path: dist - name: Zip Artifacts - run: cd ./dist - - run: zip -r ../builds/FirefoxExtensionBeta.zip * - - run: cd ../ + run: cd ./dist ; zip -r ../builds/FirefoxExtensionBeta.zip * # Create Firefox Signed Beta version - name: Create Firefox Signed Beta artifacts @@ -80,9 +67,7 @@ jobs: - name: Install rename run: sudo apt-get install rename - name: Install signed file - run: cd ./web-ext-artifacts - - run: rename 's/.*/FirefoxSignedInstaller.xpi/' * - - run: cd .. + run: cd ./web-ext-artifacts ; rename 's/.*/FirefoxSignedInstaller.xpi/' * - uses: actions/upload-artifact@v1 with: name: FirefoxExtensionSigned.xpi diff --git a/manifest/manifest.json b/manifest/manifest.json index 6c077f83..a64cbb13 100644 --- a/manifest/manifest.json +++ b/manifest/manifest.json @@ -1,7 +1,7 @@ { "name": "__MSG_fullName__", "short_name": "__MSG_Name__", - "version": "1.2.28.3", + "version": "1.2.28.4", "default_locale": "en", "description": "__MSG_Description__", "content_scripts": [{ diff --git a/public/_locales/en/messages.json b/public/_locales/en/messages.json index 864b957b..b9859414 100644 --- a/public/_locales/en/messages.json +++ b/public/_locales/en/messages.json @@ -35,9 +35,6 @@ "Segments": { "message": "sponsor segments" }, - "noticeTitle": { - "message": "Sponsor Skipped" - }, "reportButtonTitle": { "message": "Report" }, @@ -71,6 +68,9 @@ "paused": { "message": "Paused" }, + "manualPaused": { + "message": "Timer Stopped" + }, "confirmMSG": { "message": "To edit or delete individual values, click the info button or open the extension popup by clicking the extension icon in the top right corner." }, @@ -272,12 +272,12 @@ "errorCode": { "message": "Error Code: " }, - "noticeTitleNotSkipped": { - "message": "Skip Sponsor?" - }, "skip": { "message": "Skip" }, + "skipped": { + "message": "Skipped" + }, "disableAutoSkip": { "message": "Disable Auto Skip" }, @@ -559,7 +559,7 @@ "message": "Consider Enabling Force Channel Check Before Skipping Sponsors" }, "downvoteDescription": { - "message": "Incorrect" + "message": "Incorrect/Wrong Timing" }, "incorrectCategory": { "message": "Wrong Category" diff --git a/src/components/NoticeComponent.tsx b/src/components/NoticeComponent.tsx index b7ff8adf..f5e3a7af 100644 --- a/src/components/NoticeComponent.tsx +++ b/src/components/NoticeComponent.tsx @@ -23,6 +23,7 @@ export interface NoticeState { countdownTime: number, countdownText: string, + countdownManuallyPaused: boolean, } class NoticeComponent extends React.Component<NoticeProps, NoticeState> { @@ -55,6 +56,7 @@ class NoticeComponent extends React.Component<NoticeProps, NoticeState> { //the countdown until this notice closes countdownTime: maxCountdownTime(), countdownText: null, + countdownManuallyPaused: false } } @@ -71,8 +73,8 @@ class NoticeComponent extends React.Component<NoticeProps, NoticeState> { <table id={"sponsorSkipNotice" + this.idSuffix} className={"sponsorSkipObject sponsorSkipNotice" + (this.props.fadeIn ? " sponsorSkipNoticeFadeIn" : "")} style={noticeStyle} - onMouseEnter={this.pauseCountdown.bind(this)} - onMouseLeave={this.startCountdown.bind(this)}> + onMouseEnter={() => this.timerMouseEnter()} + onMouseLeave={() => this.timerMouseLeave()}> <tbody> {/* First row */} @@ -99,6 +101,7 @@ class NoticeComponent extends React.Component<NoticeProps, NoticeState> { {/* Time left */} {this.props.timed ? ( <span id={"sponsorSkipNoticeTimeLeft" + this.idSuffix} + onClick={() => this.toggleManualPause()} className="sponsorSkipObject sponsorSkipNoticeTimeLeft"> {this.state.countdownText || (this.state.countdownTime + "s")} @@ -121,6 +124,30 @@ class NoticeComponent extends React.Component<NoticeProps, NoticeState> { ); } + timerMouseEnter() { + if (this.state.countdownManuallyPaused) return; + + this.pauseCountdown(); + } + + timerMouseLeave() { + if (this.state.countdownManuallyPaused) return; + + this.startCountdown(); + } + + toggleManualPause() { + this.setState({ + countdownManuallyPaused: !this.state.countdownManuallyPaused + }, () => { + if (this.state.countdownManuallyPaused) { + this.pauseCountdown(); + } else { + this.startCountdown(); + } + }); + } + //called every second to lower the countdown before hiding the notice countdown() { if (!this.props.timed) return; @@ -159,7 +186,7 @@ class NoticeComponent extends React.Component<NoticeProps, NoticeState> { //reset countdown and inform the user this.setState({ countdownTime: this.state.maxCountdownTime(), - countdownText: chrome.i18n.getMessage("paused") + countdownText: this.state.countdownManuallyPaused ? chrome.i18n.getMessage("manualPaused") : chrome.i18n.getMessage("paused") }); //remove the fade out class if it exists diff --git a/src/components/SkipNoticeComponent.tsx b/src/components/SkipNoticeComponent.tsx index e1ecf01c..602b0ffc 100644 --- a/src/components/SkipNoticeComponent.tsx +++ b/src/components/SkipNoticeComponent.tsx @@ -62,10 +62,10 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta this.contentContainer = props.contentContainer; this.audio = null; - let noticeTitle = chrome.i18n.getMessage("noticeTitle"); + let noticeTitle = chrome.i18n.getMessage("category_" + this.getSponsorTime().category) + " " + chrome.i18n.getMessage("skipped"); if (!this.autoSkip) { - noticeTitle = chrome.i18n.getMessage("noticeTitleNotSkipped"); + noticeTitle = chrome.i18n.getMessage("skip") + " " + chrome.i18n.getMessage("category_" + this.getSponsorTime().category) + "?"; } //add notice @@ -103,6 +103,11 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta } } + // Helper method + getSponsorTime() { + return utils.getSponsorTimeFromUUID(this.contentContainer().sponsorTimes, this.UUID); + } + componentDidMount() { if (Config.config.audioNotificationOnSkip && this.audio) { this.audio.volume = this.contentContainer().v.volume * 0.1; @@ -215,7 +220,7 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta {/* Category Selector */} <select id={"sponsorTimeCategories" + this.idSuffix} className="sponsorTimeCategories" - defaultValue={utils.getSponsorTimeFromUUID(this.props.contentContainer().sponsorTimes, this.props.UUID).category} + defaultValue={this.getSponsorTime().category} ref={this.categoryOptionRef} onChange={this.categorySelectionChange.bind(this)}> @@ -319,7 +324,7 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta chrome.runtime.sendMessage({"message": "openConfig"}); // Reset option to original - event.target.value = utils.getSponsorTimeFromUUID(this.props.contentContainer().sponsorTimes, this.props.UUID).category; + event.target.value = this.getSponsorTime().category; return; } } @@ -340,7 +345,7 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta getUnskippedModeInfo(buttonText: string) { let maxCountdownTime = function() { - let sponsorTime = utils.getSponsorTimeFromUUID(this.contentContainer().sponsorTimes, this.UUID); + let sponsorTime = this.getSponsorTime(); let duration = Math.round((sponsorTime.segment[1] - this.contentContainer().v.currentTime) * (1 / this.contentContainer().v.playbackRate)); return Math.max(duration, 4); @@ -387,7 +392,7 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta this.adjustDownvotingState(false); // Change the sponsor locally - let sponsorTime = utils.getSponsorTimeFromUUID(this.contentContainer().sponsorTimes, this.UUID); + let sponsorTime = this.getSponsorTime(); if (sponsorTime) { if (type === 0) { sponsorTime.hidden = SponsorHideType.Downvoted; diff --git a/src/content.ts b/src/content.ts index d4badbbe..50ec0ec8 100644 --- a/src/content.ts +++ b/src/content.ts @@ -532,7 +532,7 @@ function startSponsorSchedule(includeIntersectingSegments: boolean = false, curr */ function incorrectVideoCheck(videoID?: string, sponsorTime?: SponsorTime): boolean { let currentVideoID = getYouTubeVideoID(document.URL); - if (currentVideoID !== (videoID || sponsorVideoID) || (sponsorTime && !sponsorTimes.includes(sponsorTime))) { + if (currentVideoID !== (videoID || sponsorVideoID) || (sponsorTime && (!sponsorTimes || !sponsorTimes.includes(sponsorTime)) && !sponsorTimesSubmitting.includes(sponsorTime))) { // Something has really gone wrong console.error("[SponsorBlock] The videoID recorded when trying to skip is different than what it should be."); console.error("[SponsorBlock] VideoID recorded: " + sponsorVideoID + ". Actual VideoID: " + currentVideoID); |