Merge pull request #349 from ajayyy/react

Hotfixes for 1.2.28.1
This commit is contained in:
Ajay Ramachandran 2020-05-12 21:56:14 -04:00 committed by GitHub
commit 50c9c9fe8a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 1672 additions and 1574 deletions

View file

@ -26,9 +26,12 @@ jobs:
name: ChromeExtension
path: dist
- run: mkdir ./builds
- name: Zip Artifacts
run: cd ./dist
- uses: montudor/action-zip@v0.1.0
with:
args: zip -qq -r ./builds/ChromeExtension.zip ./dist/*
args: zip -r ../builds/ChromeExtension.zip *
- run: cd ../
# Create Firefox artifacts
- name: Create Firefox artifacts
@ -37,9 +40,12 @@ jobs:
with:
name: FirefoxExtension
path: dist
- name: Zip Artifacts
run: cd ./dist
- uses: montudor/action-zip@v0.1.0
with:
args: zip -qq -r ./builds/FirefoxExtension.zip ./dist/*
args: zip -r ../builds/FirefoxExtension.zip *
- run: cd ../
# Create Beta artifacts (Builds with the name changed to beta)
- name: Create Chrome Beta artifacts
@ -48,9 +54,12 @@ jobs:
with:
name: ChromeExtensionBeta
path: dist
- name: Zip Artifacts
run: cd ./dist
- uses: montudor/action-zip@v0.1.0
with:
args: zip -qq -r ./builds/ChromeExtensionBeta.zip ./dist/*
args: zip -r ../builds/ChromeExtensionBeta.zip *
- run: cd ../
- name: Create Firefox Beta artifacts
run: npm run build:firefox -- --env.stream=beta
@ -58,9 +67,12 @@ jobs:
with:
name: FirefoxExtensionBeta
path: dist
- name: Zip Artifacts
run: cd ./dist
- uses: montudor/action-zip@v0.1.0
with:
args: zip -qq -r ./builds/FirefoxExtensionBeta.zip ./dist/*
args: zip -r ../builds/FirefoxExtensionBeta.zip *
- run: cd ../
# Create Firefox Signed Beta version
- name: Create Firefox Signed Beta artifacts

3171
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -15,7 +15,7 @@
"react-dom": "^16.12.0"
},
"devDependencies": {
"web-ext": "^4.0.0",
"web-ext": "^4.2.0",
"@types/chrome": "0.0.91",
"@types/firefox-webext-browser": "70.0.1",
"@types/jest": "^24.0.23",

View file

@ -260,7 +260,7 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
}
setTimeToNow(index: number) {
this.setTimeTo(index, this.props.contentContainer().getRoughCurrentTime());
this.setTimeTo(index, this.props.contentContainer().getRealCurrentTime());
}
setTimeToEnd() {

View file

@ -161,7 +161,7 @@ class SubmissionNoticeComponent extends React.Component<SubmissionNoticeProps, S
}
// Check if any non music categories are being used on a music video
if (this.contentContainer().videoInfo.microformat.playerMicroformatRenderer.category === "Music") {
if (this.contentContainer().videoInfo?.microformat?.playerMicroformatRenderer?.category === "Music") {
let sponsorTimesSubmitting = this.props.contentContainer().sponsorTimesSubmitting;
for (const sponsorTime of sponsorTimesSubmitting) {
if (!sponsorTime.category.startsWith("music_")) {

View file

@ -116,7 +116,7 @@ var skipNoticeContentContainer: ContentContainer = () => ({
changeStartSponsorButton,
previewTime,
videoInfo,
getRoughCurrentTime
getRealCurrentTime: getRealCurrentTime
});
//get messages from the background script and the popup
@ -180,7 +180,7 @@ function messageListener(request: any, sender: any, sendResponse: (response: any
return
case "getCurrentTime":
sendResponse({
currentTime: getRoughCurrentTime()
currentTime: getRealCurrentTime()
});
break;
@ -660,7 +660,7 @@ function sponsorsLookup(id: string) {
//check if this video was uploaded recently
utils.wait(() => !!videoInfo).then(() => {
let dateUploaded = videoInfo.microformat.playerMicroformatRenderer.uploadDate;
let dateUploaded = videoInfo?.microformat?.playerMicroformatRenderer?.uploadDate;
//if less than 3 days old
if (Date.now() - new Date(dateUploaded).getTime() < 259200000) {
@ -812,7 +812,12 @@ function updatePreviewBar() {
//checks if this channel is whitelisted, should be done only after the channelID has been loaded
function whitelistCheck() {
channelID = videoInfo.videoDetails.channelId;
channelID = videoInfo?.videoDetails?.channelId;
if (!channelID) {
channelID = null;
return;
}
//see if this is a whitelisted channel
let whitelistedChannels = Config.config.whitelistedChannels;
@ -1126,29 +1131,14 @@ async function updateVisibilityOfPlayerControlsButton(): Promise<boolean> {
* current time is out of date while scrubbing or at the end of the video. This is not needed
* for sponsor skipping as the video is not playing during these times.
*/
function getRoughCurrentTime(): number {
let htmlCurrentTimeString = document.querySelector(".ytp-time-current").textContent;
let htmlDurationString = document.querySelector(".ytp-time-duration").textContent;
if (htmlCurrentTimeString == htmlDurationString) {
// At the end of the video
return video.duration;
}
function getRealCurrentTime(): number {
// Used to check if replay button
let playButtonSVGData = document.querySelector("ytp-play-button")?.querySelector("ytp-svg-fill")?.getAttribute("d");
let playButtonSVGData = document.querySelector(".ytp-play-button")?.querySelector(".ytp-svg-fill")?.getAttribute("d");
let replaceSVGData = "M 18,11 V 7 l -5,5 5,5 v -4 c 3.3,0 6,2.7 6,6 0,3.3 -2.7,6 -6,6 -3.3,0 -6,-2.7 -6,-6 h -2 c 0,4.4 3.6,8 8,8 4.4,0 8,-3.6 8,-8 0,-4.4 -3.6,-8 -8,-8 z";
if (playButtonSVGData === replaceSVGData) {
// At the end of the video
return video.duration;
}
let htmlCurrentTimeSections = htmlCurrentTimeString.split(":")[0];
let htmlCurrentTime: number = parseInt(htmlCurrentTimeSections[0]) * 60 + parseInt(htmlCurrentTimeSections[1]);
if (Math.abs(video.currentTime - htmlCurrentTime) > 3) {
return htmlCurrentTime;
} else {
return video.currentTime;
}
@ -1163,11 +1153,11 @@ function startSponsorClicked() {
//add to sponsorTimes
if (sponsorTimesSubmitting.length > 0 && sponsorTimesSubmitting[sponsorTimesSubmitting.length - 1].segment.length < 2) {
//it is an end time
sponsorTimesSubmitting[sponsorTimesSubmitting.length - 1].segment[1] = getRoughCurrentTime();
sponsorTimesSubmitting[sponsorTimesSubmitting.length - 1].segment[1] = getRealCurrentTime();
} else {
//it is a start time
sponsorTimesSubmitting.push({
segment: [getRoughCurrentTime()],
segment: [getRealCurrentTime()],
UUID: null,
// Default to sponsor
category: "sponsor"
@ -1545,7 +1535,7 @@ function getSegmentsMessage(segments: number[][]): string {
* Assumes that the the privacy info is available.
*/
function isUnlisted(): boolean {
return videoInfo.microformat.playerMicroformatRenderer.isUnlisted || videoInfo.videoDetails.isPrivate;
return videoInfo?.microformat?.playerMicroformatRenderer?.isUnlisted || videoInfo?.videoDetails?.isPrivate;
}
/**

View file

@ -103,9 +103,14 @@ class PreviewBar {
categoryTooltip.classList.add("sbHidden");
});
const observer = new MutationObserver(() => {
const observer = new MutationObserver((mutations, observer) => {
if (!mouseOnSeekBar) return;
// See if mutation observed is only this ID (if so, ignore)
if (mutations.length == 1 && (mutations[0].target as HTMLElement).id === "sponsor-block-category-tooltip") {
return;
}
let tooltips = document.querySelectorAll(".ytp-tooltip-text");
for (const tooltip of tooltips) {
let splitData = tooltip.textContent.split(":");
@ -115,7 +120,7 @@ class PreviewBar {
// Find category at that location
let category = null;
for (let i = 0; i < this.timestamps.length; i++) {
for (let i = 0; i < this.timestamps?.length; i++) {
if (this.timestamps[i][0] < timeInSeconds && this.timestamps[i][1] > timeInSeconds){
category = this.types[i];
}

View file

@ -18,7 +18,7 @@ interface ContentContainer {
changeStartSponsorButton: (showStartSponsor: any, uploadButtonVisible: any) => Promise<boolean>,
previewTime: (time: number) => void,
videoInfo: any,
getRoughCurrentTime: () => number
getRealCurrentTime: () => number
}
}