Merge pull request #356 from ajayyy/react

Fix preview sponsors not skipping
This commit is contained in:
Ajay Ramachandran 2020-05-17 00:00:08 -04:00 committed by GitHub
commit 45d20574d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 55 additions and 38 deletions

View file

@ -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/action-zip@v0.1.0
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

View file

@ -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": [{

View file

@ -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"

View file

@ -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

View file

@ -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;

View file

@ -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);