diff --git a/YoutubeConfig.json b/YoutubeConfig.json index fa3ac8471f2f2080816d6184af43eee83f7720d2..1b8efdf35f31951efe19445cf64c2da85899a3f7 100644 --- a/YoutubeConfig.json +++ b/YoutubeConfig.json @@ -7,7 +7,7 @@ "sourceUrl": "https://plugins.grayjay.app/Youtube/YoutubeConfig.json", "repositoryUrl": "https://futo.org", "scriptUrl": "./YoutubeScript.js", - "version": 148, + "version": 151, "iconUrl": "./youtube.png", "id": "35ae969a-a7db-11ed-afa1-0242ac120002", @@ -36,28 +36,19 @@ ], "settings": [ - { - "variable": "youtubeDislikes", - "name": "Return YoutubeDislike", - "description": "Use Return YoutubeDislike to provide dislikes for videos", - "type": "Boolean", - "default": "false" - }, { "variable": "authChannels", "name": "Use Login for Channels", "description": "Use authenticated client for channel (videos) requests. (eg. for member videos)", "type": "Boolean", - "default": "false", - "warningDialog": "Known bug: if your Youtube language is not English, this will cause wrong dates." + "default": "false" }, { "variable": "authDetails", "name": "Use Login for video details", "description": "Use authenticated client for video requests. (eg. for member videos)", "type": "Boolean", - "default": "false", - "warningDialog": "Known bug: if your Youtube language is not English, this will cause wrong dates." + "default": "false" }, { "variable": "youtubeActivity", @@ -73,10 +64,23 @@ "type": "Boolean", "default": "false" }, + { + "variable": "youtubeDislikerHeader", + "name": "Return Youtube Dislike", + "description": "This is a third-party database of video dislikes that combines historic data, crowd-sourced data, and estimations, and may not be accurate.\n\n(Using https://returnyoutubedislike.com)", + "type": "Header" + }, + { + "variable": "youtubeDislikes", + "name": "Enable", + "description": "Use Return YoutubeDislike to provide dislikes for videos", + "type": "Boolean", + "default": "false" + }, { "variable": "sponsorBlockHeader", "name": "SponsorBlock", - "description": "This is NOT Adblock. SponsorBlock allows you to (automatically) skip in-video sponsor segments.\nIt will harm creators.\n\nFUTO respects your decision to use SponsorBlock. But only if you're supprting creators in other ways.", + "description": "This is NOT Adblock. SponsorBlock allows you to (automatically) skip in-video sponsor segments.\nIt will harm creators.\n\n(Using https://sponsor.ajay.app)\n\nFUTO respects your decision to use SponsorBlock. But only if you're supprting creators in other ways.", "type": "Header" }, { diff --git a/YoutubeScript.js b/YoutubeScript.js index df1a02d643956797617c8639da798b870b3d148f..f4c4dc3716420d971a1e3d20a1db7836c5fd822a 100644 --- a/YoutubeScript.js +++ b/YoutubeScript.js @@ -323,6 +323,7 @@ source.getContentDetails = (url, useAuth) => { const headersUsed = (useLogin) ? getAuthContextHeaders(false) : {}; headersUsed["Accept-Language"] = "en-US"; + headersUsed["Cookie"] = "PREF=hl=en&gl=US" const batch = http.batch().GET(url, headersUsed, useLogin); @@ -478,8 +479,8 @@ source.getContentChapters = function(url, initialData) { (allowNoVoteSkip || block.votes >= 1)) { sbChapters.push({ name: block.category, - timeStart: parseInt(block.segment[0]), - timeEnd: parseInt(block.segment[1]), + timeStart: parseFloat(block.segment[0]), + timeEnd: parseFloat(block.segment[1]), type: skipType }); } @@ -514,7 +515,7 @@ function mergeSBChapters(videoChapters, sbChapters) { for(let videoChapter of videoChapters) { const sponsors = sbChapters.filter(x=> x.timeStart >= videoChapter.timeStart && - x.timeEnd <= videoChapter.timeEnd); + x.timeStart <= videoChapter.timeEnd); if(sponsors.length > 0) { let startTime = videoChapter.timeStart; let skip = false; @@ -547,8 +548,11 @@ function mergeSBChapters(videoChapters, sbChapters) { else { newChapters.push(videoChapterBefore); newChapters.push(sponsor); - newChapters.push(videoChapterAfter); - startTime = videoChapterAfter.timeEnd; + if(videoChapterAfter.timeStart < videoChapterAfter.timeEnd) { + newChapters.push(videoChapterAfter); + startTime = videoChapterAfter.timeEnd; + } + else startTime = videoChapterAfter.timeStart; } } } @@ -1747,10 +1751,11 @@ function requestPage(url, headers, useAuth = false) { else throw new ScriptException("Failed to request page [" + resp.code + "]"); } function requestInitialData(url, useMobile = false, useAuth = false) { - let headers = {"Accept-Language": "en-US" }; + let headers = {"Accept-Language": "en-US", "Cookie": "PREF=hl=en&gl=US" }; if(useMobile) headers["User-Agent"] = USER_AGENT_TABLET; + const resp = http.GET(url, headers, useAuth); throwIfCaptcha(resp); if(resp.isOk) { diff --git a/sign.sh b/sign.sh index bcd4fcc4c45561294d6a0cd69492441da71f08a4..7cf0905297023e2357841fb3c93515a82d8c5ea6 100644 --- a/sign.sh +++ b/sign.sh @@ -25,11 +25,5 @@ echo "PUBLIC_KEY: $PUBLIC_KEY" # Remove temporary key files rm tmp_private_key.pem -# Read existing Config JSON into variable -CONFIG_JSON=$(cat $CONFIG_FILE_PATH) - # Update "scriptSignature" and "scriptPublicKey" fields in Config JSON -UPDATED_CONFIG_JSON=$(echo "$CONFIG_JSON" | jq --arg signature "$SIGNATURE" --arg publicKey "$PUBLIC_KEY" '. + {scriptSignature: $signature, scriptPublicKey: $publicKey}') - -# Write updated JSON back to Config JSON file -echo "$UPDATED_CONFIG_JSON" > $CONFIG_FILE_PATH +cat $CONFIG_FILE_PATH | jq --arg signature "$SIGNATURE" --arg publicKey "$PUBLIC_KEY" '. + {scriptSignature: $signature, scriptPublicKey: $publicKey}' > temp_config.json && mv temp_config.json $CONFIG_FILE_PATH \ No newline at end of file