mirror of
https://github.com/Alvin-Zilverstand/return-youtube-dislike.git
synced 2026-10-28 07:40:27 +01:00
Formatting, static site style
This commit is contained in:
@@ -16,122 +16,124 @@
|
||||
// @grant GM_xmlhttpRequest
|
||||
// ==/UserScript==
|
||||
function getButtons() {
|
||||
return document
|
||||
.getElementById("menu-container")
|
||||
?.querySelector("#top-level-buttons-computed");
|
||||
return document
|
||||
.getElementById("menu-container")
|
||||
?.querySelector("#top-level-buttons-computed");
|
||||
}
|
||||
|
||||
function getLikeButton() {
|
||||
return getButtons().children[0];
|
||||
return getButtons().children[0];
|
||||
}
|
||||
|
||||
function getDislikeButton() {
|
||||
return getButtons().children[1];
|
||||
return getButtons().children[1];
|
||||
}
|
||||
|
||||
function isVideoLiked() {
|
||||
return getLikeButton().classList.contains("style-default-active");
|
||||
return getLikeButton().classList.contains("style-default-active");
|
||||
}
|
||||
|
||||
function isVideoDisliked() {
|
||||
return getDislikeButton().classList.contains("style-default-active");
|
||||
return getDislikeButton().classList.contains("style-default-active");
|
||||
}
|
||||
|
||||
function isVideoNotLiked() {
|
||||
return getLikeButton().classList.contains("style-text");
|
||||
return getLikeButton().classList.contains("style-text");
|
||||
}
|
||||
|
||||
function isVideoNotDisliked() {
|
||||
return getDislikeButton().classList.contains("style-text");
|
||||
return getDislikeButton().classList.contains("style-text");
|
||||
}
|
||||
|
||||
function getState() {
|
||||
if (isVideoLiked()) {
|
||||
return "liked";
|
||||
}
|
||||
if (isVideoDisliked()) {
|
||||
return "disliked";
|
||||
}
|
||||
return "neutral";
|
||||
if (isVideoLiked()) {
|
||||
return "liked";
|
||||
}
|
||||
if (isVideoDisliked()) {
|
||||
return "disliked";
|
||||
}
|
||||
return "neutral";
|
||||
}
|
||||
|
||||
function setLikes(likesCount) {
|
||||
getButtons().children[0].querySelector("#text").innerText = likesCount;
|
||||
getButtons().children[0].querySelector("#text").innerText = likesCount;
|
||||
}
|
||||
|
||||
function setDislikes(dislikesCount) {
|
||||
getButtons().children[1].querySelector("#text").innerText = dislikesCount;
|
||||
getButtons().children[1].querySelector("#text").innerText = dislikesCount;
|
||||
}
|
||||
|
||||
function setState() {
|
||||
GM_xmlhttpRequest({
|
||||
method: "GET",
|
||||
responseType: "json",
|
||||
url: "https://return-youtube-dislike-api.azurewebsites.net/votes?videoId=" + getVideoId(),
|
||||
onload: function(response) {
|
||||
if (response != undefined) {
|
||||
const formattedDislike = numberFormat(response.response.dislikes);
|
||||
console.log(response);
|
||||
setDislikes(formattedDislike);
|
||||
}
|
||||
}
|
||||
});
|
||||
GM_xmlhttpRequest({
|
||||
method: "GET",
|
||||
responseType: "json",
|
||||
url:
|
||||
"https://return-youtube-dislike-api.azurewebsites.net/votes?videoId=" +
|
||||
getVideoId(),
|
||||
onload: function (response) {
|
||||
if (response != undefined) {
|
||||
const formattedDislike = numberFormat(response.response.dislikes);
|
||||
console.log(response);
|
||||
setDislikes(formattedDislike);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function likeClicked() {
|
||||
console.log("like" + getState());
|
||||
setState();
|
||||
console.log("like" + getState());
|
||||
setState();
|
||||
}
|
||||
|
||||
function dislikeClicked() {
|
||||
console.log("dislike" + getState());
|
||||
setState();
|
||||
console.log("dislike" + getState());
|
||||
setState();
|
||||
}
|
||||
|
||||
function setInitalState() {
|
||||
setState();
|
||||
setState();
|
||||
}
|
||||
|
||||
function getVideoId() {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const videoId = urlParams.get("v");
|
||||
return videoId;
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const videoId = urlParams.get("v");
|
||||
return videoId;
|
||||
}
|
||||
|
||||
function isVideoLoaded() {
|
||||
const videoId = getVideoId();
|
||||
return (
|
||||
document.querySelector(`ytd-watch-flexy[video-id='${videoId}']`) !== null
|
||||
);
|
||||
const videoId = getVideoId();
|
||||
return (
|
||||
document.querySelector(`ytd-watch-flexy[video-id='${videoId}']`) !== null
|
||||
);
|
||||
}
|
||||
|
||||
function numberFormat(numberState) {
|
||||
const userLocales = navigator.language;
|
||||
const formatter = Intl.NumberFormat(userLocales, { notation: "compact" });
|
||||
return formatter.format(numberState);
|
||||
const userLocales = navigator.language;
|
||||
const formatter = Intl.NumberFormat(userLocales, { notation: "compact" });
|
||||
return formatter.format(numberState);
|
||||
}
|
||||
|
||||
function setEventListeners(evt) {
|
||||
function checkForJS_Finish() {
|
||||
if (getButtons()?.offsetParent && isVideoLoaded()) {
|
||||
clearInterval(jsInitChecktimer);
|
||||
const buttons = getButtons();
|
||||
if (!window.returnDislikeButtonlistenersSet) {
|
||||
buttons.children[0].addEventListener("click", likeClicked);
|
||||
buttons.children[1].addEventListener("click", dislikeClicked);
|
||||
window.returnDislikeButtonlistenersSet = true;
|
||||
}
|
||||
setInitalState();
|
||||
}
|
||||
function checkForJS_Finish() {
|
||||
if (getButtons()?.offsetParent && isVideoLoaded()) {
|
||||
clearInterval(jsInitChecktimer);
|
||||
const buttons = getButtons();
|
||||
if (!window.returnDislikeButtonlistenersSet) {
|
||||
buttons.children[0].addEventListener("click", likeClicked);
|
||||
buttons.children[1].addEventListener("click", dislikeClicked);
|
||||
window.returnDislikeButtonlistenersSet = true;
|
||||
}
|
||||
setInitalState();
|
||||
}
|
||||
}
|
||||
|
||||
if (window.location.href.indexOf("watch?") >= 0) {
|
||||
var jsInitChecktimer = setInterval(checkForJS_Finish, 111);
|
||||
}
|
||||
if (window.location.href.indexOf("watch?") >= 0) {
|
||||
var jsInitChecktimer = setInterval(checkForJS_Finish, 111);
|
||||
}
|
||||
}
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
window.addEventListener("yt-navigate-finish", setEventListeners, true);
|
||||
setEventListeners();
|
||||
(function () {
|
||||
"use strict";
|
||||
window.addEventListener("yt-navigate-finish", setEventListeners, true);
|
||||
setEventListeners();
|
||||
})();
|
||||
|
||||
+45
-37
@@ -12,39 +12,42 @@
|
||||
<title>Return youtube dislike count</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="/">Return youtube dislike count</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarNav">
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#downloads">Downloads</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#installation">Installation</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#faq">FAQ</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#communication">Communication</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#sources">Sources</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||
<div class="container-xxl">
|
||||
<a class="navbar-brand" href="/">Return youtube dislike count</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
|
||||
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarNav">
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#downloads">Downloads</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#installation">Installation</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#faq">FAQ</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#communication">Communication</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#sources">Sources</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-lg-8 col-md-10 col-sm-12">
|
||||
<h3 class="mt-4">Chrome/Firefox/Usersript extension to return youtube dislike count</h3>
|
||||
<img src="images/aAGrY8L_700b.jpg" class="img-fluid"/>
|
||||
|
||||
|
||||
|
||||
<p><strong>Version 0.0.0.5 released - ratio (like/dislike) bar added</strong></p>
|
||||
<img class="img-fluid mb-5" src="images/ratio.jpg"/>
|
||||
@@ -79,18 +82,19 @@
|
||||
<a href="files/chrome/return_youtube_dislike0.0.0.1.crx">v_0.0.0.1</a></p>
|
||||
<p><a href="files/chrome/return_youtube_dislike0.0.0.2.crx">v_0.0.0.2</a> - Better number formatting added,
|
||||
<p><a href="files/chrome/return_youtube_dislike_LOAD_UNPACKED_0.0.0.3.zip">v_0.0.0.3</a>
|
||||
<p> 0.0.0.4 <strong> removed (accidental self-ddos)</strong></p>
|
||||
<p> <a href="files/chrome/return_youtube_dislike_LOAD_UNPACKED_0.0.0.5.zip">0.0.0.5</a>
|
||||
- ratio bar added. Dislikes from every video on page are saved now
|
||||
<p> 0.0.0.4 <strong> removed (accidental self-ddos)</strong></p>
|
||||
<p><a href="files/chrome/return_youtube_dislike_LOAD_UNPACKED_0.0.0.5.zip">0.0.0.5</a>
|
||||
- ratio bar added. Dislikes from every video on page are saved now
|
||||
|
||||
Previous versions are disabled automatically by chrome, because Chrome doesn't like .crx extensions.
|
||||
Previous versions are disabled automatically by chrome, because Chrome doesn't like .crx extensions.
|
||||
|
||||
Install this following new instructions.
|
||||
Install this following new instructions.
|
||||
</p>
|
||||
|
||||
<h4>Firefox:</h4>
|
||||
|
||||
Install from extension's firefox addon store <a href="https://addons.mozilla.org/en-US/firefox/addon/return-youtube-dislikes/" target="_blank">page</a>.
|
||||
Install from extension's firefox addon store <a
|
||||
href="https://addons.mozilla.org/en-US/firefox/addon/return-youtube-dislikes/" target="_blank">page</a>.
|
||||
Check for updates often - this extension is being actively improved
|
||||
Latest version coming out as soon as update is approved by Mozilla
|
||||
|
||||
@@ -108,12 +112,15 @@
|
||||
<div class="accordion-body">
|
||||
<div class="card card-body">
|
||||
|
||||
<p> NOT RECOMMENDED! Use firefox addon store <a href="https://addons.mozilla.org/en-US/firefox/addon/return-youtube-dislikes/" target="_blank">link</a>
|
||||
<p> NOT RECOMMENDED! Use firefox addon store <a
|
||||
href="https://addons.mozilla.org/en-US/firefox/addon/return-youtube-dislikes/"
|
||||
target="_blank">link</a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="files/ff/youtube_dislike_button-0.0.0.1-fx.xpi">v_0.0.0.1</a>
|
||||
</p>
|
||||
<p><a href="files/ff/youtube_dislike_button-0.0.0.2-fx.xpi">v_0.0.0.2</a> - Better number formatting added
|
||||
<p><a href="files/ff/youtube_dislike_button-0.0.0.2-fx.xpi">v_0.0.0.2</a> - Better number formatting
|
||||
added
|
||||
thanks, <strong>bstka</strong>
|
||||
</p>
|
||||
</div>
|
||||
@@ -134,7 +141,8 @@
|
||||
<h2>Installation on chrome</h2>
|
||||
<p></p><strong>Before installing new version - please manually delete old version</strong></p>
|
||||
<p></p><strong>Chrome might disable this extension - you'll need to delete it and reinstall. </strong>
|
||||
This is a temporary problem while awaiting chrome store approval. You might use userscript or firefox extension meanwhile.</p>
|
||||
This is a temporary problem while awaiting chrome store approval. You might use userscript or firefox extension
|
||||
meanwhile.</p>
|
||||
|
||||
|
||||
<p> Installation is described for Chrome. For firefox extension is available in store</p>
|
||||
|
||||
Reference in New Issue
Block a user