sendVideoIds removed, sponsor links updated

This commit is contained in:
Dmitrii Selivanov
2022-04-26 23:05:26 +02:00
parent bdc28cad33
commit a4806c1f47
9 changed files with 62 additions and 79 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
"name": "__MSG_extensionName__",
"description": "__MSG_extensionDesc__",
"default_locale": "en",
"version": "3.0.0.0",
"version": "3.0.0.1",
"manifest_version": 3,
"background": {
"service_worker": "ryd.background.js"
+1 -1
View File
@@ -2,7 +2,7 @@
"name": "__MSG_extensionName__",
"description": "__MSG_extensionDesc__",
"default_locale": "en",
"version": "3.0.0.0",
"version": "3.0.0.1",
"manifest_version": 2,
"background": {
"scripts": ["ryd.background.js"]
+10 -10
View File
@@ -73,16 +73,16 @@ api.runtime.onMessage.addListener((request, sender, sendResponse) => {
}
});
api.storage.sync.get(['lastShowChangelogVersion'], (details) => {
if (extConfig.showUpdatePopup === true &&
details.lastShowChangelogVersion !== chrome.runtime.getManifest().version
) {
// keep it inside get to avoid race condition
api.storage.sync.set({'lastShowChangelogVersion ': chrome.runtime.getManifest().version});
// 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.storage.sync.get(['lastShowChangelogVersion'], (details) => {
// if (extConfig.showUpdatePopup === true &&
// details.lastShowChangelogVersion !== chrome.runtime.getManifest().version
// ) {
// // keep it inside get to avoid race condition
// api.storage.sync.set({'lastShowChangelogVersion ': chrome.runtime.getManifest().version});
// // 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});
// }
// });
async function sendVote(videoId, vote) {
api.storage.sync.get(null, async (storageResult) => {
@@ -34,7 +34,6 @@ import {
} from "./src/utils";
import { createRateBar } from "./src/bar";
import {
sendVideoIds,
sendVote,
likeClicked,
dislikeClicked,
@@ -67,5 +66,3 @@ document.addEventListener("yt-navigate-finish", function (event) {
window.returnDislikeButtonlistenersSet = false;
setEventListeners();
});
setTimeout(() => sendVideoIds(), 2500);
-27
View File
@@ -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() {
if (checkForSignInButton() === false) {
if (storedData.previousState === DISLIKED_STATE) {
@@ -166,7 +140,6 @@ function handleNumberDisplayReformatLikesChangeEvent(value) {
export {
sendVote,
sendVideoIds,
likeClicked,
dislikeClicked,
addLikeDislikeEventListener,
+45 -29
View File
@@ -7,7 +7,6 @@ import {
numberFormat,
getColorFromTheme,
} from "./utils";
import { sendVideoIds } from "./events";
import { localize } from "./utils";
//TODO: Do not duplicate here and in ryd.background.js
@@ -40,35 +39,43 @@ function isShorts() {
return location.pathname.startsWith("/shorts");
}
let mutationObserver = new Object();
if (isShorts() && mutationObserver.exists !== true) {
cLog('initializing mutation observer')
cLog("initializing mutation observer");
mutationObserver.options = {
childList: false,
attributes: true,
subtree: false
subtree: false,
};
mutationObserver.exists = true;
mutationObserver.observer = new MutationObserver( function(mutationList, observer) {
mutationList.forEach( (mutation) => {
if (mutation.type === 'attributes' &&
mutation.target.nodeName === 'TP-YT-PAPER-BUTTON' &&
mutation.target.id === 'button') {
mutationObserver.observer = new MutationObserver(function (
mutationList,
observer
) {
mutationList.forEach((mutation) => {
if (
mutation.type === "attributes" &&
mutation.target.nodeName === "TP-YT-PAPER-BUTTON" &&
mutation.target.id === "button"
) {
// 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.parentElement.parentElement.id === 'like-button') ?
getColorFromTheme(true) : getColorFromTheme(false);
mutation.target.parentElement.parentElement.id === "like-button"
? getColorFromTheme(true)
: getColorFromTheme(false);
} else {
mutation.target.style.color = 'unset';
mutation.target.style.color = "unset";
}
return;
}
cLog('unexpected mutation observer event: ' + mutation.target + mutation.type);
cLog(
"unexpected mutation observer event: " + mutation.target + mutation.type
);
});
});
}
function isLikesDisabled() {
// 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
);
}
return /^\D*$/.test(getButtons().children[0].querySelector("#text").innerText);
return /^\D*$/.test(
getButtons().children[0].querySelector("#text").innerText
);
}
function isVideoLiked() {
@@ -132,9 +141,8 @@ function setDislikes(dislikesCount) {
).innerText = localize("TextLikesDisabled");
return;
}
getButtons().children[1].querySelector("#text").innerText = localize(
"TextLikesDisabled"
);
getButtons().children[1].querySelector("#text").innerText =
localize("TextLikesDisabled");
}
}
@@ -164,17 +172,28 @@ function processResponse(response, storedData) {
storedData.likes = getLikeCountFromButton() || parseInt(response.likes);
createRateBar(storedData.likes, storedData.dislikes);
if (extConfig.coloredThumbs === true) {
if (isShorts()) { // for shorts, leave deactived buttons in default color
let shortLikeButton = getLikeButton().querySelector('tp-yt-paper-button#button');
let shortDislikeButton = getDislikeButton().querySelector('tp-yt-paper-button#button');
if (shortLikeButton.getAttribute('aria-pressed') === 'true') {
if (isShorts()) {
// for shorts, leave deactived buttons in default color
let shortLikeButton = getLikeButton().querySelector(
"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);
}
if (shortDislikeButton.getAttribute('aria-pressed') === 'true') {
if (shortDislikeButton.getAttribute("aria-pressed") === "true") {
shortDislikeButton.style.color = getColorFromTheme(false);
}
mutationObserver.observer.observe(shortLikeButton, mutationObserver.options);
mutationObserver.observer.observe(shortDislikeButton, mutationObserver.options);
mutationObserver.observer.observe(
shortLikeButton,
mutationObserver.options
);
mutationObserver.observer.observe(
shortDislikeButton,
mutationObserver.options
);
} else {
getLikeButton().style.color = getColorFromTheme(true);
getDislikeButton().style.color = getColorFromTheme(false);
@@ -224,9 +243,6 @@ async function setState(storedData) {
function setInitialState() {
setState(storedData);
setTimeout(() => {
sendVideoIds();
}, 1500);
}
function initExtConfig() {
@@ -326,5 +342,5 @@ export {
extConfig,
initExtConfig,
storedData,
isLikesDisabled
isLikesDisabled,
};
+4 -7
View File
@@ -67,7 +67,7 @@
</h3>
</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">
<v-icon class="mb-2">mdi-heart</v-icon>
Sponsors
@@ -105,12 +105,6 @@ export default {
discordLink: "https://discord.gg/mYnESY4Md5",
sponsors: [
{ 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",
link: "https://www.seed4.me/users/register?gift=ReturnYoutubeDislike",
@@ -118,6 +112,9 @@ export default {
{
name: "PocketTube",
link: "https://yousub.info/?utm_source=returnyoutubedislike"
}, {
name: "Become our sponsor",
link: "https://www.patreon.com/join/returnyoutubedislike/checkout?rid=8008601"
}
],
};
+1 -1
View File
@@ -22,7 +22,7 @@
<v-btn class="mainAltButton" :href="emailLink" target="_blank">
<v-icon style="margin-right: 0.5em">mdi-email</v-icon>
Email
selivano.d@gmail.com
</v-btn>
<p id="credits" class="flex-row no-wrap">