2.1.0 release

This commit is contained in:
Dmitrii Selivanov committed 2022-01-08 23:22:29 +03:00
1 parent a43811f2d7
commit cebe938ce0
6 files changed
+73 -38

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "Return YouTube Dislike", "name": "Return YouTube Dislike",
"description": "Returns ability to see dislikes", "description": "Returns ability to see dislikes",
"version": "2.0.0.3", "version": "2.1.0.0",
"manifest_version": 3, "manifest_version": 3,
"background": { "background": {
"service_worker": "ryd.background.js" "service_worker": "ryd.background.js"
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "Return YouTube Dislike", "name": "Return YouTube Dislike",
"description": "Returns ability to see dislikes", "description": "Returns ability to see dislikes",
"version": "2.0.0.3", "version": "2.1.0.0",
"manifest_version": 2, "manifest_version": 2,
"background": { "background": {
"scripts": ["ryd.background.js"] "scripts": ["ryd.background.js"]
+24 -8
View File
@@ -20,8 +20,8 @@
/> />
<path d="m8 12.5 5.1-2.9L8 6.7v5.8z" fill="#fff" /> <path d="m8 12.5 5.1-2.9L8 6.7v5.8z" fill="#fff" />
</svg> </svg>
<h1 style="margin-bottom: .75rem;">Return YouTube Dislike</h1> <h1 style="margin-bottom: 0.75rem">Return YouTube Dislike</h1>
<p style="color: var(--lightGrey);">by Dmitrii Selivanov & Community</p> <p style="color: var(--lightGrey)">by Dmitrii Selivanov & Community</p>
<button id="link_website">Website</button> <button id="link_website">Website</button>
<button id="link_github">GitHub</button> <button id="link_github">GitHub</button>
@@ -29,14 +29,19 @@
<br /> <br />
<button style="margin-top: .3rem" id="link_faq">FAQ</button> <button style="margin-top: 0.3rem" id="link_faq">FAQ</button>
<button style="margin-top: .3em" id="link_donate">Donate</button> <button style="margin-top: 0.3em" id="link_donate">Donate</button>
<br /> <br />
<br /> <br />
<p style="display: inline-block;">API Status: <b id="status"></b></p> <p style="display: none">API Status: <b id="status"></b></p>
<img id="server-status" style="display: inline-block; width: .75rem; height: .75rem;" src="./icons/server.svg" alt="" /> <img
id="server-status"
style="display: none; width: 0.75rem; height: 0.75rem"
src="./icons/server.svg"
alt=""
/>
<br /> <br />
<br /> <br />
@@ -44,7 +49,19 @@
<!-- top-right --> <!-- top-right -->
<button id="advancedToggle"> <button id="advancedToggle">
<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor"><rect fill="none" height="24" width="24"/><path d="M19.5,12c0-0.23-0.01-0.45-0.03-0.68l1.86-1.41c0.4-0.3,0.51-0.86,0.26-1.3l-1.87-3.23c-0.25-0.44-0.79-0.62-1.25-0.42 l-2.15,0.91c-0.37-0.26-0.76-0.49-1.17-0.68l-0.29-2.31C14.8,2.38,14.37,2,13.87,2h-3.73C9.63,2,9.2,2.38,9.14,2.88L8.85,5.19 c-0.41,0.19-0.8,0.42-1.17,0.68L5.53,4.96c-0.46-0.2-1-0.02-1.25,0.42L2.41,8.62c-0.25,0.44-0.14,0.99,0.26,1.3l1.86,1.41 C4.51,11.55,4.5,11.77,4.5,12s0.01,0.45,0.03,0.68l-1.86,1.41c-0.4,0.3-0.51,0.86-0.26,1.3l1.87,3.23c0.25,0.44,0.79,0.62,1.25,0.42 l2.15-0.91c0.37,0.26,0.76,0.49,1.17,0.68l0.29,2.31C9.2,21.62,9.63,22,10.13,22h3.73c0.5,0,0.93-0.38,0.99-0.88l0.29-2.31 c0.41-0.19,0.8-0.42,1.17-0.68l2.15,0.91c0.46,0.2,1,0.02,1.25-0.42l1.87-3.23c0.25-0.44,0.14-0.99-0.26-1.3l-1.86-1.41 C19.49,12.45,19.5,12.23,19.5,12z M12.04,15.5c-1.93,0-3.5-1.57-3.5-3.5s1.57-3.5,3.5-3.5s3.5,1.57,3.5,3.5S13.97,15.5,12.04,15.5z"/></svg> <svg
xmlns="http://www.w3.org/2000/svg"
enable-background="new 0 0 24 24"
height="24px"
viewBox="0 0 24 24"
width="24px"
fill="currentColor"
>
<rect fill="none" height="24" width="24" />
<path
d="M19.5,12c0-0.23-0.01-0.45-0.03-0.68l1.86-1.41c0.4-0.3,0.51-0.86,0.26-1.3l-1.87-3.23c-0.25-0.44-0.79-0.62-1.25-0.42 l-2.15,0.91c-0.37-0.26-0.76-0.49-1.17-0.68l-0.29-2.31C14.8,2.38,14.37,2,13.87,2h-3.73C9.63,2,9.2,2.38,9.14,2.88L8.85,5.19 c-0.41,0.19-0.8,0.42-1.17,0.68L5.53,4.96c-0.46-0.2-1-0.02-1.25,0.42L2.41,8.62c-0.25,0.44-0.14,0.99,0.26,1.3l1.86,1.41 C4.51,11.55,4.5,11.77,4.5,12s0.01,0.45,0.03,0.68l-1.86,1.41c-0.4,0.3-0.51,0.86-0.26,1.3l1.87,3.23c0.25,0.44,0.79,0.62,1.25,0.42 l2.15-0.91c0.37,0.26,0.76,0.49,1.17,0.68l0.29,2.31C9.2,21.62,9.63,22,10.13,22h3.73c0.5,0,0.93-0.38,0.99-0.88l0.29-2.31 c0.41-0.19,0.8-0.42,1.17-0.68l2.15,0.91c0.46,0.2,1,0.02,1.25-0.42l1.87-3.23c0.25-0.44,0.14-0.99-0.26-1.3l-1.86-1.41 C19.49,12.45,19.5,12.23,19.5,12z M12.04,15.5c-1.93,0-3.5-1.57-3.5-3.5s1.57-3.5,3.5-3.5s3.5,1.57,3.5,3.5S13.97,15.5,12.04,15.5z"
/>
</svg>
</button> </button>
<!-- bottom-right --> <!-- bottom-right -->
@@ -79,7 +96,6 @@
</label> </label>
<br /> --> <br /> -->
<!-- <label class="switch"> <!-- <label class="switch">
<input type="checkbox" id="disable_api_unlisted" /> <input type="checkbox" id="disable_api_unlisted" />
<span class="slider" /> <span class="slider" />
+11 -6
View File
@@ -28,12 +28,17 @@ api.runtime.onMessage.addListener((request, sender, sendResponse) => {
} else if (request.message == "set_state") { } else if (request.message == "set_state") {
// chrome.identity.getAuthToken({ interactive: true }, function (token) { // chrome.identity.getAuthToken({ interactive: true }, function (token) {
let token = ""; let token = "";
fetch(`${apiUrl}/votes?videoId=${request.videoId}&likeCount=${request.likeCount || ''}`, { fetch(
method: "GET", `${apiUrl}/votes?videoId=${request.videoId}&likeCount=${
headers: { request.likeCount || ""
Accept: "application/json", }`,
}, {
}) method: "GET",
headers: {
Accept: "application/json",
},
}
)
.then((response) => response.json()) .then((response) => response.json())
.then((response) => { .then((response) => {
sendResponse(response); sendResponse(response);
+24 -18
View File
@@ -3,6 +3,8 @@ import { createRateBar } from "./bar";
import { getBrowser, getVideoId, cLog, numberFormat } from "./utils"; import { getBrowser, getVideoId, cLog, numberFormat } from "./utils";
import { sendVideoIds } from "./events"; import { sendVideoIds } from "./events";
//TODO: Do not duplicate here and in ryd.background.js
const apiUrl = "https://returnyoutubedislikeapi.com";
const LIKED_STATE = "LIKED_STATE"; const LIKED_STATE = "LIKED_STATE";
const DISLIKED_STATE = "DISLIKED_STATE"; const DISLIKED_STATE = "DISLIKED_STATE";
const NEUTRAL_STATE = "NEUTRAL_STATE"; const NEUTRAL_STATE = "NEUTRAL_STATE";
@@ -98,7 +100,7 @@ function processResponse(response, storedData) {
createRateBar(storedData.likes, storedData.dislikes); createRateBar(storedData.likes, storedData.dislikes);
} }
function setState(storedData) { async function setState(storedData) {
storedData.previousState = isVideoDisliked() storedData.previousState = isVideoDisliked()
? DISLIKED_STATE ? DISLIKED_STATE
: isVideoLiked() : isVideoLiked()
@@ -106,25 +108,29 @@ function setState(storedData) {
: NEUTRAL_STATE; : NEUTRAL_STATE;
let statsSet = false; let statsSet = false;
getBrowser().runtime.sendMessage( let videoId = getVideoId(window.location.href);
let likeCount = getLikeCountFromButton() || null;
let response = await fetch(
`${apiUrl}/votes?videoId=${videoId}&likeCount=${likeCount || ""}`,
{ {
message: "set_state", method: "GET",
videoId: getVideoId(window.location.href), headers: {
state: getState(storedData).current, Accept: "application/json",
likeCount: getLikeCountFromButton() || null, },
},
function (response) {
cLog("response from api:");
cLog(JSON.stringify(response));
likesDisabledState =
numberFormat(response.dislikes) == 0 &&
numberFormat(response.likes) == 0 &&
numberFormat(response.viewCount) == 0;
if (response !== undefined && !("traceId" in response) && !statsSet) {
processResponse(response, storedData);
}
} }
); )
.then((response) => response.json())
.catch();
cLog("response from api:");
cLog(JSON.stringify(response));
likesDisabledState =
numberFormat(response.dislikes) == 0 &&
numberFormat(response.likes) == 0 &&
numberFormat(response.viewCount) == 0;
if (response !== undefined && !("traceId" in response) && !statsSet) {
processResponse(response, storedData);
}
} }
function setInitialState() { function setInitialState() {
+12 -4
View File
@@ -13,7 +13,7 @@ module.exports = {
minimize: false, minimize: false,
}, },
watchOptions: { watchOptions: {
ignored: "./Extensions/combined/dist/*" ignored: "./Extensions/combined/dist/*",
}, },
plugins: [ plugins: [
// exclude locale files in moment // exclude locale files in moment
@@ -50,15 +50,23 @@ module.exports = {
{ {
from: "./Extensions/combined/manifest-firefox.json", from: "./Extensions/combined/manifest-firefox.json",
to: "./firefox/manifest.json", to: "./firefox/manifest.json",
} },
], ],
}), }),
new FileManagerPlugin({ new FileManagerPlugin({
events: { events: {
onEnd: { onEnd: {
copy: [ copy: [
{ source: "./Extensions/combined/dist/bundled-content-script.js", destination: "./Extensions/combined/dist/firefox/bundled-content-script.js" }, {
{ source: "./Extensions/combined/dist/bundled-content-script.js", destination: "./Extensions/combined/dist/chrome/bundled-content-script.js" }, source: "./Extensions/combined/dist/bundled-content-script.js",
destination:
"./Extensions/combined/dist/firefox/bundled-content-script.js",
},
{
source: "./Extensions/combined/dist/bundled-content-script.js",
destination:
"./Extensions/combined/dist/chrome/bundled-content-script.js",
},
], ],
}, },
}, },