Compare commits

..

9 Commits

Author SHA1 Message Date
Ajay Ramachandran
50c9c9fe8a Merge pull request #349 from ajayyy/react
Hotfixes for 1.2.28.1
2020-05-12 21:56:14 -04:00
Ajay Ramachandran
7f8badb34d New Crowdin translations (#348)
* New translations messages.json (Chinese Simplified)

* New translations messages.json (Chinese Simplified)
2020-05-12 21:55:43 -04:00
Ajay Ramachandran
f9d8daeca0 Upgraded web-ext 2020-05-12 21:18:07 -04:00
Ajay Ramachandran
55070d5852 Fixed mutation listener stack overflow on Firefox. 2020-05-12 21:17:52 -04:00
Ajay Ramachandran
789bd5939b Fixed zipping command in release workflow 2020-05-11 21:13:19 -04:00
Ajay Ramachandran
b591fbfc4b Removed log 2020-05-11 21:04:28 -04:00
Ajay Ramachandran
57eb122fce Changed rough time calculation to only use real time or end time.
Also fixed getting the replay button element.
2020-05-11 21:04:10 -04:00
Ajay Ramachandran
aec287f0cf Fixed preview bar hover text error 2020-05-11 20:59:30 -04:00
Ajay Ramachandran
c68aabaa40 Added null coalescence checks to video info 2020-05-11 20:45:48 -04:00
9 changed files with 1696 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

3169
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

@@ -350,6 +350,9 @@
"supportInvidious": {
"message": "支持 Invidious"
},
"supportInvidiousDescription": {
"message": "Invidious (invidio.us) 是一个第三方 Youtube 客户端。要启用支持,您必须允许额外的权限。在 Chrome 及其他 Chromium 变种的匿名模式中无法工作。"
},
"optionsInfo": {
"message": "启用 Invidious 支持,禁用自动跳过,隐藏按钮等等。"
},
@@ -486,9 +489,21 @@
"category_sponsor": {
"message": "赞助商广告"
},
"category_intro": {
"message": "介绍动画"
},
"category_interaction": {
"message": "互动提醒(订阅)"
},
"category_selfpromo": {
"message": "自我推销和商品"
},
"category_music_offtopic": {
"message": "音乐:非音乐部分"
},
"category_livestream_messages": {
"message": "直播:捐赠/消息阅读"
},
"disable": {
"message": "禁用"
},
@@ -539,5 +554,14 @@
},
"forceChannelCheckPopup": {
"message": "请考虑启用跳过赞助商广告前强制进行频道检查"
},
"downvoteDescription": {
"message": "不正确"
},
"incorrectCategory": {
"message": "错误的类别"
},
"nonMusicCategoryOnMusic": {
"message": "此视频被归类为音乐。您确定要提交带有非音乐类别的片段吗?除非此视频实际上不是音乐,否则您不应提交此片段。如果您感到困惑,请阅读指南。"
}
}

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