mirror of
https://github.com/Alvin-Zilverstand/return-youtube-dislike.git
synced 2026-12-03 03:11:23 +01:00
sendVideoIds removed, sponsor links updated
This commit is contained in:
1 parent
bdc28cad33
commit
a4806c1f47
9 files changed
+62
-79
No files matched your search
File renamed without changes.
@@ -2,7 +2,7 @@
|
|||||||
"name": "__MSG_extensionName__",
|
"name": "__MSG_extensionName__",
|
||||||
"description": "__MSG_extensionDesc__",
|
"description": "__MSG_extensionDesc__",
|
||||||
"default_locale": "en",
|
"default_locale": "en",
|
||||||
"version": "3.0.0.0",
|
"version": "3.0.0.1",
|
||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"background": {
|
"background": {
|
||||||
"service_worker": "ryd.background.js"
|
"service_worker": "ryd.background.js"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"name": "__MSG_extensionName__",
|
"name": "__MSG_extensionName__",
|
||||||
"description": "__MSG_extensionDesc__",
|
"description": "__MSG_extensionDesc__",
|
||||||
"default_locale": "en",
|
"default_locale": "en",
|
||||||
"version": "3.0.0.0",
|
"version": "3.0.0.1",
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"background": {
|
"background": {
|
||||||
"scripts": ["ryd.background.js"]
|
"scripts": ["ryd.background.js"]
|
||||||
|
|||||||
@@ -73,16 +73,16 @@ api.runtime.onMessage.addListener((request, sender, sendResponse) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
api.storage.sync.get(['lastShowChangelogVersion'], (details) => {
|
// api.storage.sync.get(['lastShowChangelogVersion'], (details) => {
|
||||||
if (extConfig.showUpdatePopup === true &&
|
// if (extConfig.showUpdatePopup === true &&
|
||||||
details.lastShowChangelogVersion !== chrome.runtime.getManifest().version
|
// details.lastShowChangelogVersion !== chrome.runtime.getManifest().version
|
||||||
) {
|
// ) {
|
||||||
// keep it inside get to avoid race condition
|
// // keep it inside get to avoid race condition
|
||||||
api.storage.sync.set({'lastShowChangelogVersion ': chrome.runtime.getManifest().version});
|
// api.storage.sync.set({'lastShowChangelogVersion ': chrome.runtime.getManifest().version});
|
||||||
// wait until async get runs & don't steal tab focus
|
// // wait until async get runs & don't steal tab focus
|
||||||
api.tabs.create({url: api.runtime.getURL("/changelog/3/changelog_3.0.html"), active: false});
|
// api.tabs.create({url: api.runtime.getURL("/changelog/3/changelog_3.0.html"), active: false});
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
|
||||||
async function sendVote(videoId, vote) {
|
async function sendVote(videoId, vote) {
|
||||||
api.storage.sync.get(null, async (storageResult) => {
|
api.storage.sync.get(null, async (storageResult) => {
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ import {
|
|||||||
} from "./src/utils";
|
} from "./src/utils";
|
||||||
import { createRateBar } from "./src/bar";
|
import { createRateBar } from "./src/bar";
|
||||||
import {
|
import {
|
||||||
sendVideoIds,
|
|
||||||
sendVote,
|
sendVote,
|
||||||
likeClicked,
|
likeClicked,
|
||||||
dislikeClicked,
|
dislikeClicked,
|
||||||
@@ -67,5 +66,3 @@ document.addEventListener("yt-navigate-finish", function (event) {
|
|||||||
window.returnDislikeButtonlistenersSet = false;
|
window.returnDislikeButtonlistenersSet = false;
|
||||||
setEventListeners();
|
setEventListeners();
|
||||||
});
|
});
|
||||||
|
|
||||||
setTimeout(() => sendVideoIds(), 2500);
|
|
||||||
@@ -21,32 +21,6 @@ function sendVote(vote) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendVideoIds() {
|
|
||||||
let links = Array.from(
|
|
||||||
document.getElementsByClassName(
|
|
||||||
"yt-simple-endpoint ytd-compact-video-renderer"
|
|
||||||
)
|
|
||||||
).concat(
|
|
||||||
Array.from(
|
|
||||||
document.getElementsByClassName("yt-simple-endpoint ytd-thumbnail")
|
|
||||||
)
|
|
||||||
);
|
|
||||||
// Also try mobile
|
|
||||||
if (links.length < 1)
|
|
||||||
links = Array.from(
|
|
||||||
document.querySelectorAll(
|
|
||||||
".large-media-item-metadata > a, a.large-media-item-thumbnail-container"
|
|
||||||
)
|
|
||||||
);
|
|
||||||
const ids = links
|
|
||||||
.filter((x) => x.href && x.href.indexOf("/watch?v=") > 0)
|
|
||||||
.map((x) => getVideoId(x.href));
|
|
||||||
getBrowser().runtime.sendMessage({
|
|
||||||
message: "send_links",
|
|
||||||
videoIds: ids,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function likeClicked() {
|
function likeClicked() {
|
||||||
if (checkForSignInButton() === false) {
|
if (checkForSignInButton() === false) {
|
||||||
if (storedData.previousState === DISLIKED_STATE) {
|
if (storedData.previousState === DISLIKED_STATE) {
|
||||||
@@ -166,7 +140,6 @@ function handleNumberDisplayReformatLikesChangeEvent(value) {
|
|||||||
|
|
||||||
export {
|
export {
|
||||||
sendVote,
|
sendVote,
|
||||||
sendVideoIds,
|
|
||||||
likeClicked,
|
likeClicked,
|
||||||
dislikeClicked,
|
dislikeClicked,
|
||||||
addLikeDislikeEventListener,
|
addLikeDislikeEventListener,
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import {
|
|||||||
numberFormat,
|
numberFormat,
|
||||||
getColorFromTheme,
|
getColorFromTheme,
|
||||||
} from "./utils";
|
} from "./utils";
|
||||||
import { sendVideoIds } from "./events";
|
|
||||||
import { localize } from "./utils";
|
import { localize } from "./utils";
|
||||||
|
|
||||||
//TODO: Do not duplicate here and in ryd.background.js
|
//TODO: Do not duplicate here and in ryd.background.js
|
||||||
@@ -40,35 +39,43 @@ function isShorts() {
|
|||||||
return location.pathname.startsWith("/shorts");
|
return location.pathname.startsWith("/shorts");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let mutationObserver = new Object();
|
let mutationObserver = new Object();
|
||||||
|
|
||||||
if (isShorts() && mutationObserver.exists !== true) {
|
if (isShorts() && mutationObserver.exists !== true) {
|
||||||
cLog('initializing mutation observer')
|
cLog("initializing mutation observer");
|
||||||
mutationObserver.options = {
|
mutationObserver.options = {
|
||||||
childList: false,
|
childList: false,
|
||||||
attributes: true,
|
attributes: true,
|
||||||
subtree: false
|
subtree: false,
|
||||||
};
|
};
|
||||||
mutationObserver.exists = true;
|
mutationObserver.exists = true;
|
||||||
mutationObserver.observer = new MutationObserver( function(mutationList, observer) {
|
mutationObserver.observer = new MutationObserver(function (
|
||||||
mutationList.forEach( (mutation) => {
|
mutationList,
|
||||||
if (mutation.type === 'attributes' &&
|
observer
|
||||||
mutation.target.nodeName === 'TP-YT-PAPER-BUTTON' &&
|
) {
|
||||||
mutation.target.id === 'button') {
|
mutationList.forEach((mutation) => {
|
||||||
|
if (
|
||||||
|
mutation.type === "attributes" &&
|
||||||
|
mutation.target.nodeName === "TP-YT-PAPER-BUTTON" &&
|
||||||
|
mutation.target.id === "button"
|
||||||
|
) {
|
||||||
// cLog('Short thumb button status changed');
|
// cLog('Short thumb button status changed');
|
||||||
if (mutation.target.getAttribute('aria-pressed') === 'true') {
|
if (mutation.target.getAttribute("aria-pressed") === "true") {
|
||||||
mutation.target.style.color =
|
mutation.target.style.color =
|
||||||
(mutation.target.parentElement.parentElement.id === 'like-button') ?
|
mutation.target.parentElement.parentElement.id === "like-button"
|
||||||
getColorFromTheme(true) : getColorFromTheme(false);
|
? getColorFromTheme(true)
|
||||||
|
: getColorFromTheme(false);
|
||||||
} else {
|
} else {
|
||||||
mutation.target.style.color = 'unset';
|
mutation.target.style.color = "unset";
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cLog('unexpected mutation observer event: ' + mutation.target + mutation.type);
|
cLog(
|
||||||
|
"unexpected mutation observer event: " + mutation.target + mutation.type
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function isLikesDisabled() {
|
function isLikesDisabled() {
|
||||||
// return true if the like button's text doesn't contain any number
|
// return true if the like button's text doesn't contain any number
|
||||||
@@ -77,7 +84,9 @@ function isLikesDisabled() {
|
|||||||
getButtons().children[0].querySelector(".button-renderer-text").innerText
|
getButtons().children[0].querySelector(".button-renderer-text").innerText
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return /^\D*$/.test(getButtons().children[0].querySelector("#text").innerText);
|
return /^\D*$/.test(
|
||||||
|
getButtons().children[0].querySelector("#text").innerText
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isVideoLiked() {
|
function isVideoLiked() {
|
||||||
@@ -132,9 +141,8 @@ function setDislikes(dislikesCount) {
|
|||||||
).innerText = localize("TextLikesDisabled");
|
).innerText = localize("TextLikesDisabled");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
getButtons().children[1].querySelector("#text").innerText = localize(
|
getButtons().children[1].querySelector("#text").innerText =
|
||||||
"TextLikesDisabled"
|
localize("TextLikesDisabled");
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,17 +172,28 @@ function processResponse(response, storedData) {
|
|||||||
storedData.likes = getLikeCountFromButton() || parseInt(response.likes);
|
storedData.likes = getLikeCountFromButton() || parseInt(response.likes);
|
||||||
createRateBar(storedData.likes, storedData.dislikes);
|
createRateBar(storedData.likes, storedData.dislikes);
|
||||||
if (extConfig.coloredThumbs === true) {
|
if (extConfig.coloredThumbs === true) {
|
||||||
if (isShorts()) { // for shorts, leave deactived buttons in default color
|
if (isShorts()) {
|
||||||
let shortLikeButton = getLikeButton().querySelector('tp-yt-paper-button#button');
|
// for shorts, leave deactived buttons in default color
|
||||||
let shortDislikeButton = getDislikeButton().querySelector('tp-yt-paper-button#button');
|
let shortLikeButton = getLikeButton().querySelector(
|
||||||
if (shortLikeButton.getAttribute('aria-pressed') === 'true') {
|
"tp-yt-paper-button#button"
|
||||||
|
);
|
||||||
|
let shortDislikeButton = getDislikeButton().querySelector(
|
||||||
|
"tp-yt-paper-button#button"
|
||||||
|
);
|
||||||
|
if (shortLikeButton.getAttribute("aria-pressed") === "true") {
|
||||||
shortLikeButton.style.color = getColorFromTheme(true);
|
shortLikeButton.style.color = getColorFromTheme(true);
|
||||||
}
|
}
|
||||||
if (shortDislikeButton.getAttribute('aria-pressed') === 'true') {
|
if (shortDislikeButton.getAttribute("aria-pressed") === "true") {
|
||||||
shortDislikeButton.style.color = getColorFromTheme(false);
|
shortDislikeButton.style.color = getColorFromTheme(false);
|
||||||
}
|
}
|
||||||
mutationObserver.observer.observe(shortLikeButton, mutationObserver.options);
|
mutationObserver.observer.observe(
|
||||||
mutationObserver.observer.observe(shortDislikeButton, mutationObserver.options);
|
shortLikeButton,
|
||||||
|
mutationObserver.options
|
||||||
|
);
|
||||||
|
mutationObserver.observer.observe(
|
||||||
|
shortDislikeButton,
|
||||||
|
mutationObserver.options
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
getLikeButton().style.color = getColorFromTheme(true);
|
getLikeButton().style.color = getColorFromTheme(true);
|
||||||
getDislikeButton().style.color = getColorFromTheme(false);
|
getDislikeButton().style.color = getColorFromTheme(false);
|
||||||
@@ -224,9 +243,6 @@ async function setState(storedData) {
|
|||||||
|
|
||||||
function setInitialState() {
|
function setInitialState() {
|
||||||
setState(storedData);
|
setState(storedData);
|
||||||
setTimeout(() => {
|
|
||||||
sendVideoIds();
|
|
||||||
}, 1500);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function initExtConfig() {
|
function initExtConfig() {
|
||||||
@@ -326,5 +342,5 @@ export {
|
|||||||
extConfig,
|
extConfig,
|
||||||
initExtConfig,
|
initExtConfig,
|
||||||
storedData,
|
storedData,
|
||||||
isLikesDisabled
|
isLikesDisabled,
|
||||||
};
|
};
|
||||||
@@ -67,7 +67,7 @@
|
|||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="cool-people" class="d-flex flex-column items-center py-8">
|
<div id="biggest-supporters" class="d-flex flex-column items-center py-8">
|
||||||
<h3 class="mb-4">
|
<h3 class="mb-4">
|
||||||
<v-icon class="mb-2">mdi-heart</v-icon>
|
<v-icon class="mb-2">mdi-heart</v-icon>
|
||||||
Sponsors
|
Sponsors
|
||||||
@@ -105,12 +105,6 @@ export default {
|
|||||||
discordLink: "https://discord.gg/mYnESY4Md5",
|
discordLink: "https://discord.gg/mYnESY4Md5",
|
||||||
sponsors: [
|
sponsors: [
|
||||||
{ name: "Piepacker", link: "https://piepacker.com/" },
|
{ name: "Piepacker", link: "https://piepacker.com/" },
|
||||||
{ name: "nodetube", link: "https://github.com/mayeaux/nodetube" },
|
|
||||||
{ name: "trig404" },
|
|
||||||
{
|
|
||||||
name: "Peter33",
|
|
||||||
link: "https://www.youtube.com/watch?v=G5kzUpWAusI",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "Seed4.Me VPN",
|
name: "Seed4.Me VPN",
|
||||||
link: "https://www.seed4.me/users/register?gift=ReturnYoutubeDislike",
|
link: "https://www.seed4.me/users/register?gift=ReturnYoutubeDislike",
|
||||||
@@ -118,6 +112,9 @@ export default {
|
|||||||
{
|
{
|
||||||
name: "PocketTube",
|
name: "PocketTube",
|
||||||
link: "https://yousub.info/?utm_source=returnyoutubedislike"
|
link: "https://yousub.info/?utm_source=returnyoutubedislike"
|
||||||
|
}, {
|
||||||
|
name: "Become our sponsor",
|
||||||
|
link: "https://www.patreon.com/join/returnyoutubedislike/checkout?rid=8008601"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
<v-btn class="mainAltButton" :href="emailLink" target="_blank">
|
<v-btn class="mainAltButton" :href="emailLink" target="_blank">
|
||||||
<v-icon style="margin-right: 0.5em">mdi-email</v-icon>
|
<v-icon style="margin-right: 0.5em">mdi-email</v-icon>
|
||||||
Email
|
selivano.d@gmail.com
|
||||||
</v-btn>
|
</v-btn>
|
||||||
|
|
||||||
<p id="credits" class="flex-row no-wrap">
|
<p id="credits" class="flex-row no-wrap">
|
||||||
|
|||||||
Reference in new issue
Block a user