您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Restore like and dislike count for any Invidious Instance
当前为
- // ==UserScript==
- // @name Invidious Like and Dislike Count
- // @namespace http://tampermonkey.net/
- // @version 1.1
- // @description Restore like and dislike count for any Invidious Instance
- // @author KMan005
- // @match https://iv.ggtyler.dev/*
- // @grant GM_xmlhttpRequest
- // @license MIT
- // ==/UserScript==
- (function() {
- 'use strict';
- // Get the video ID from the URL
- const urlParams = new URLSearchParams(window.location.search);
- const videoId = urlParams.get('v');
- // Fetch the like and dislike count
- GM_xmlhttpRequest({
- method: "GET",
- url: `https://returnyoutubedislikeapi.com/votes?videoId=${videoId}`,
- headers: {
- "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9",
- "Pragma": "no-cache",
- "Cache-Control": "no-cache",
- "Connection": "keep-alive"
- },
- onload: function(response) {
- const data = JSON.parse(response.responseText);
- const likeCount = data.likes;
- const dislikeCount = data.dislikes;
- // Display the like count on the webpage within the specified <p> element
- const likesElement = document.getElementById('likes');
- likesElement.innerHTML = `<i class="icon ion-ios-thumbs-up"></i> ${likeCount}`;
- // Display the dislike count on the webpage within the specified <p> element
- const dislikesElement = document.getElementById('dislikes');
- dislikesElement.textContent = `Dislikes: ${dislikeCount}`;
- // Ensure visibility and display properties stay consistent for both elements
- likesElement.style.visibility = 'visible';
- likesElement.style.display = 'block';
- dislikesElement.style.visibility = 'visible';
- dislikesElement.style.display = 'block';
- }
- });
- // Apply CSS styles to the specified <p> elements
- const styleElement = document.createElement('style');
- styleElement.textContent = `
- p#likes, p#dislikes {
- display: block;
- visibility: visible;
- unicode-bidi: plaintext;
- text-align: start;
- margin-block-start: 1em;
- margin-block-end: 1em;
- margin-inline-start: 0px;
- margin-inline-end: 0px;
- overflow-wrap: break-word;
- word-wrap: break-word;
- font-family: sans-serif;
- }
- `;
- document.head.appendChild(styleElement);
- })();