|
@@ -2,7 +2,7 @@
|
|
// @name Return YouTube Dislike
|
|
// @name Return YouTube Dislike
|
|
// @namespace https://www.returnyoutubedislike.com/
|
|
// @namespace https://www.returnyoutubedislike.com/
|
|
// @homepage https://www.returnyoutubedislike.com/
|
|
// @homepage https://www.returnyoutubedislike.com/
|
|
-// @version 0.6.1
|
|
|
|
|
|
+// @version 0.9.0
|
|
// @encoding utf-8
|
|
// @encoding utf-8
|
|
// @description Return of the YouTube Dislike, Based off https://www.returnyoutubedislike.com/
|
|
// @description Return of the YouTube Dislike, Based off https://www.returnyoutubedislike.com/
|
|
// @icon https://github.com/Anarios/return-youtube-dislike/raw/main/Icons/Return%20Youtube%20Dislike%20-%20Transparent.png
|
|
// @icon https://github.com/Anarios/return-youtube-dislike/raw/main/Icons/Return%20Youtube%20Dislike%20-%20Transparent.png
|
|
@@ -217,49 +217,6 @@ function createRateBar(likes, dislikes) {
|
|
function setState() {
|
|
function setState() {
|
|
cLog("Fetching votes...");
|
|
cLog("Fetching votes...");
|
|
let statsSet = false;
|
|
let statsSet = false;
|
|
- if (isMobile) {
|
|
|
|
- GM.xmlHttpRequest({
|
|
|
|
- method: "GET",
|
|
|
|
- url: `https://www.youtube.com/watch?v=${getVideoId()}`,
|
|
|
|
- headers: {
|
|
|
|
- "User-Agent":
|
|
|
|
- "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.3674",
|
|
|
|
- },
|
|
|
|
- onload: (response) => {
|
|
|
|
- let result = getDislikesFromYoutubeResponse(response.responseText);
|
|
|
|
- if (result) {
|
|
|
|
- cLog("response from youtube:");
|
|
|
|
- cLog(JSON.stringify(result));
|
|
|
|
- if ("likes" in result && "dislikes" in result) {
|
|
|
|
- const formattedDislike = numberFormat(result.dislikes);
|
|
|
|
- setDislikes(formattedDislike);
|
|
|
|
- likesvalue = result.likes
|
|
|
|
- dislikesvalue = result.dislikes
|
|
|
|
- createRateBar(result.likes, result.dislikes);
|
|
|
|
- statsSet = true;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- });
|
|
|
|
- } else {
|
|
|
|
- fetch(`https://www.youtube.com/watch?v=${getVideoId()}`).then((response) => {
|
|
|
|
- response.text().then((text) => {
|
|
|
|
- let result = getDislikesFromYoutubeResponse(text);
|
|
|
|
- if (result) {
|
|
|
|
- cLog("response from youtube:");
|
|
|
|
- cLog(JSON.stringify(result));
|
|
|
|
- if ("likes" in result && "dislikes" in result) {
|
|
|
|
- const formattedDislike = numberFormat(result.dislikes);
|
|
|
|
- setDislikes(formattedDislike);
|
|
|
|
- likesvalue = result.likes;
|
|
|
|
- dislikesvalue = result.dislikes;
|
|
|
|
- createRateBar(result.likes, result.dislikes);
|
|
|
|
- statsSet = true;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
|
|
|
|
fetch(
|
|
fetch(
|
|
`https://returnyoutubedislikeapi.com/votes?videoId=${getVideoId()}`
|
|
`https://returnyoutubedislikeapi.com/votes?videoId=${getVideoId()}`
|
|
@@ -357,7 +314,7 @@ function numberFormat(numberState) {
|
|
let localeURL = Array.from(document.querySelectorAll("head > link[rel='search']"))
|
|
let localeURL = Array.from(document.querySelectorAll("head > link[rel='search']"))
|
|
?.find((n) => n?.getAttribute("href")?.includes("?locale="))
|
|
?.find((n) => n?.getAttribute("href")?.includes("?locale="))
|
|
?.getAttribute("href");
|
|
?.getAttribute("href");
|
|
-
|
|
|
|
|
|
+
|
|
const userLocales = localeURL ? new URL(localeURL)?.searchParams?.get("locale") : document.body.lang;
|
|
const userLocales = localeURL ? new URL(localeURL)?.searchParams?.get("locale") : document.body.lang;
|
|
|
|
|
|
const formatter = Intl.NumberFormat(
|
|
const formatter = Intl.NumberFormat(
|
|
@@ -405,7 +362,7 @@ function getDislikesFromYoutubeResponse(htmlResponse) {
|
|
|
|
|
|
function setEventListeners(evt) {
|
|
function setEventListeners(evt) {
|
|
let jsInitChecktimer;
|
|
let jsInitChecktimer;
|
|
-
|
|
|
|
|
|
+
|
|
function checkForJS_Finish(check) {
|
|
function checkForJS_Finish(check) {
|
|
console.log();
|
|
console.log();
|
|
if (getButtons()?.offsetParent && isVideoLoaded()) {
|
|
if (getButtons()?.offsetParent && isVideoLoaded()) {
|