Greasy Fork镜像 支持简体中文。

Ans youtube GUI (ADBLOCKER, VOLUME CHANGER, 15+ MODS)

Tools for youtube, these tools let you modify the likes, video title, subscribers and views of the vid, dm me on dc if you want me to add ur idea

目前為 2025-01-28 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Ans youtube GUI (ADBLOCKER, VOLUME CHANGER, 15+ MODS)
  3. // @name:fi Anin Youtube käyttöliittymä (MAINOSESTÄJÄ, ÄÄNITASON VAIHTAJA, 15+ MODIFIKAATIOTA)
  4. // @namespace http://tampermonkey.net/
  5. // @version 1.1.3
  6. // @description Tools for youtube, these tools let you modify the likes, video title, subscribers and views of the vid, dm me on dc if you want me to add ur idea
  7. // @description:fi Työkaluja youtubeen nämä työkalut antaa sinun modifioida tykkäyksiä, videon nimeä, tilaajia ja videon katselukertoja, lähetä viestiä discordissa jos haluat että minä lisään ideasi.
  8. // @author @theyhoppingonme on discord
  9. // @match https://www.youtube.com/*
  10. // @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16. //patch logs:
  17. // V1.0.0: GUI released
  18. // V1.0.1: Adblock
  19. // V1.0.2: Just a simple name change and patch logs
  20. // V1.0.3 Added more unsubscribe button filters
  21. // V1.0.4 New GUI name
  22. // V1.0.5 Added desc changer
  23. // V1.0.6 Added pinned comment name changer
  24. // V1.0.7 Added volume changer (bass boost epic), video width changer, video height changer, video duration changer, video time watched changer
  25. // V1.0.8 Ad block has been fixed and enhanced as well as the unsubscribing, before you had to unsubscribe first manually but now its fully functional!
  26. // V1.0.9 Adblock is ACTUALLY fixed sorry for the inconvinience it was broken a bit
  27. // V1.1.0 Added change search placeholder
  28. // V1.1.1 Fixed Description Filtering
  29. // V1.1.2 new epic UI
  30. // V1.1.3 Fixed the video height and width changing, made gui look a bit better
  31.  
  32. function isYouTubeShort() {
  33. const currentURL = window.location.href;
  34. if (currentURL.includes('youtube.com/shorts/')) {
  35. console.log('Mostly everything is bugged on shorts, if you wish to use the script on this video, go and watch the non-short version.');
  36. }
  37. }
  38. isYouTubeShort();
  39.  
  40. function isLiveChat() {
  41. const currentURL = window.location.href;
  42. if (currentURL.includes('youtube.com/live_chat')) {
  43. return;
  44. }
  45. }
  46. isLiveChat();
  47. const style = document.createElement('style'); // style for the menu
  48. style.textContent = `
  49. .container {
  50. text-align: center;
  51. width: 90%;
  52. max-width: 800px;
  53. padding: 20px 30px;
  54. background-color: #222;
  55. border-radius: 12px;
  56. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
  57. font-family: 'Arial', sans-serif;
  58. color: white;
  59. position: fixed;
  60. top: 20px;
  61. right: 20px;
  62. z-index: 10000;
  63. transition: box-shadow 0.3s ease-in-out, background-color 0.3s ease;
  64. }
  65. button {
  66. background-color: #444;
  67. border: none;
  68. color: white;
  69. font-size: 11px;
  70. padding: 6px 9px;
  71. margin: 5px;
  72. cursor: pointer;
  73. transition: background-color 0.2s ease, transform 0.2s ease;
  74. }
  75. button:hover {
  76. background-color: #6B3EFF;
  77. transform: scale(1.05);
  78. }
  79. .close-button, .minimize-button {
  80. position: absolute;
  81. top: 12px;
  82. background-color: transparent;
  83. border: none;
  84. color: white;
  85. font-size: 20px;
  86. cursor: pointer;
  87. transition: color 0.2s ease;
  88. }
  89. .close-button {
  90. right: 40px;
  91. }
  92. .minimize-button {
  93. right: 0px;
  94. }
  95. .close-button:hover, .minimize-button:hover {
  96. color: #6B3EFF;
  97. }
  98. `;
  99. document.head.appendChild(style);
  100. const container = document.createElement('div'); //Creating the menu
  101. container.className = 'container';
  102. document.body.appendChild(container);
  103.  
  104. const title = document.createElement('h1'); // menu name
  105. const nameElement = document.getElementById("account-name");
  106. const name = nameElement ? nameElement.textContent.trim() : "Guest";
  107. title.textContent = "Ans Youtube GUI V1.1.3";
  108. container.appendChild(title);
  109.  
  110. const closeButton = document.createElement('button'); // close button
  111. closeButton.className = 'close-button';
  112. closeButton.textContent = 'X';
  113. container.appendChild(closeButton);
  114. closeButton.addEventListener('click', () => {
  115. container.style.display = 'none';
  116. });
  117. // minimize menu (button not shown, press insert to minimize)
  118. const minimizeButton = document.createElement('button');
  119. minimizeButton.className = 'minimize-button';
  120. minimizeButton.textContent = '';
  121. container.appendChild(minimizeButton);
  122. minimizeButton.addEventListener('click', () => {
  123. container.style.display = 'none';
  124. });
  125.  
  126. const inputs = [ // inputs
  127. { placeholder: 'Fake likes', action: setFakeLikes },
  128. { placeholder: 'Fake subs', action: setFakeSubs },
  129. { placeholder: 'Fake views', action: setFakeViews },
  130. { placeholder: 'Change Title', action: setChangeTitle },
  131. { placeholder: 'Change ChannelName', action: setFakeName },
  132. { placeholder: 'Change Playbackspeed', action: setPlaybackSpeed },
  133. { placeholder: 'Fake Description', action: setDesc },
  134. { placeholder: 'Fake CommentPinner', action: setPinner },
  135. { placeholder: 'Change volume', action: setVolume },
  136. { placeholder: 'Video Height', action: setHeight },
  137. { placeholder: 'Video Width', action: setWidth },
  138. { placeholder: 'Video Duration', action: setDuration },
  139. { placeholder: 'Set TimeWatched (seconds)', action: setTime },
  140. { placeholder: 'Set SearchPlaceholder', action: setSearch }
  141. ];
  142.  
  143. function createInputButton(inputConfig) { // creating input buttons
  144. const input = document.createElement('input');
  145. input.type = 'text';
  146. input.placeholder = inputConfig.placeholder;
  147. container.appendChild(input);
  148.  
  149. const button = document.createElement('button');
  150. button.textContent = `Set ${inputConfig.placeholder.split(' ')[1]}`;
  151. container.appendChild(button);
  152.  
  153. button.addEventListener('click', () => {
  154. inputConfig.action(input.value);
  155. });
  156. }
  157.  
  158. function createToggleButton(label, enableFunction, disableFunction) { // creating toggles
  159. const toggleContainer = document.createElement('div');
  160. toggleContainer.style.marginTop = '10px';
  161. container.appendChild(toggleContainer);
  162.  
  163. const labelElement = document.createElement('span');
  164. labelElement.textContent = label;
  165. labelElement.style.marginRight = '10px';
  166. toggleContainer.appendChild(labelElement);
  167.  
  168. const toggleButton = document.createElement('button');
  169. toggleButton.textContent = 'OFF';
  170. toggleButton.style.padding = '5px 10px';
  171. toggleButton.style.cursor = 'pointer';
  172. toggleContainer.appendChild(toggleButton);
  173.  
  174. let isToggled = false;
  175.  
  176. toggleButton.addEventListener('click', () => {
  177. isToggled = !isToggled;
  178. toggleButton.textContent = isToggled ? 'ON' : 'OFF';
  179. toggleButton.style.backgroundColor = isToggled ? '#6B3EFF' : '';
  180.  
  181. if (isToggled) {
  182. enableFunction();
  183. } else {
  184. disableFunction();
  185. }
  186. });
  187. }
  188.  
  189. const Adblock = () => {
  190. const scrub = document.querySelector('.ytp-fine-scrubbing')
  191. const player = document.querySelector('#movie_player')
  192. const adyesno = player.classList.contains('ad-showing')
  193. const vid = player.querySelector('video.html5-main-video')
  194. if (adyesno) {
  195. const skip = document.querySelector(`
  196. .ytp-skip-ad-button,
  197. .ytp-ad-skip-button,
  198. .ytp-ad-skip-button-modern,
  199. .ytp-ad-survey-answer-button
  200. `)
  201. if (skip) {
  202. skip.click()
  203. skip.remove()
  204. }
  205. else if (vid && vid.src) {
  206. vid.currentTime = 9999999999;
  207. }
  208. }
  209. const adSelectors = [
  210. '.ytp-ad-module',
  211. '.ytp-ad-text',
  212. '.ad-interrupting',
  213. '.video-ads',
  214. '.ytp-ad-image-overlay'
  215. ];
  216.  
  217. const links = [
  218. 'about:blank'
  219. ];
  220.  
  221. const skipButton = document.querySelector('.ytp-ad-skip-button');
  222. if (skipButton) skipButton.click();
  223.  
  224. adSelectors.forEach(selector => {
  225. document.querySelectorAll(selector).forEach(ad => {
  226. ad.currentTime = ad.duration;
  227. });
  228. });
  229.  
  230. function checkAndSkipAd() {
  231. const adBadge = document.querySelector('.ad-simple-attributed-string.ytp-ad-badge__text#ad-simple-attributed-string\\:a[aria-label="Sponsored"]');
  232.  
  233. if (adBadge) {
  234. const vid = document.querySelector('video');
  235. if (vid) {
  236. vid.currentTime = 9489278134234324323424234;
  237. console.log('Ad detected and ad skipped.');
  238. }
  239. }
  240. }
  241.  
  242. const observer = new MutationObserver(() => {
  243. checkAndSkipAd();
  244. });
  245.  
  246. observer.observe(document.body, {
  247. childList: true,
  248. subtree: true,
  249. });
  250.  
  251. checkAndSkipAd();
  252.  
  253. };
  254.  
  255.  
  256.  
  257. const reenableAds = () => {
  258. const skipButton = document.querySelector('.ytp-ad-skip-button');
  259. if (skipButton) skipButton.style.display = 'block';
  260.  
  261. const overlayAd = document.querySelector('.ytp-ad-overlay-slot');
  262. if (overlayAd) overlayAd.style.display = 'block';
  263.  
  264. const bannerAd = document.querySelector('.ytp-ce-element');
  265. if (bannerAd) bannerAd.style.display = 'block';
  266.  
  267. const adFrame = document.querySelector('iframe[src*="ads"]');
  268. if (adFrame) adFrame.style.display = 'block';
  269.  
  270. const adSelectors = [
  271. '.ytp-ad-player-overlay',
  272. '.ytp-ad-module',
  273. '.ytp-ad-text',
  274. '.ad-interrupting',
  275. '.video-ads',
  276. '.ytp-ad-image-overlay'
  277. ];
  278.  
  279. adSelectors.forEach(selector => {
  280. document.querySelectorAll(selector).forEach(ad => {
  281. ad.style.display = 'block';
  282. });
  283. });
  284. const originalFetch = window.fetch;
  285. window.fetch = originalFetch;
  286.  
  287. const originalXhrOpen = XMLHttpRequest.prototype.open;
  288. XMLHttpRequest.prototype.open = originalXhrOpen;
  289. };
  290.  
  291. createToggleButton('Toggle YouTube Ad Blocker', Adblock, reenableAds);
  292. // ad block
  293.  
  294. createToggleButton('Toggle Mute', // mute button, emulates the M key press
  295. () => {
  296. const keyEvent = new KeyboardEvent('keydown', {
  297. key: 'm',
  298. code: 'KeyM',
  299. keyCode: 77,
  300. which: 77,
  301. bubbles: true,
  302. cancelable: true
  303. });
  304. document.dispatchEvent(keyEvent);
  305. },
  306. () => {
  307. const keyEvent = new KeyboardEvent('keydown', {
  308. key: 'm',
  309. code: 'KeyM',
  310. keyCode: 77,
  311. which: 77,
  312. bubbles: true,
  313. cancelable: true
  314. });
  315. document.dispatchEvent(keyEvent);
  316. }
  317. );
  318.  
  319. createToggleButton(
  320. 'Toggle subscription',
  321. () => {
  322. const subscribeButton = document.querySelector('.yt-spec-button-shape-next.yt-spec-button-shape-next--filled.yt-spec-button-shape-next--mono.yt-spec-button-shape-next--size-m');
  323.  
  324. if (subscribeButton) {
  325. const clickEvent = new MouseEvent('click', {
  326. bubbles: true,
  327. cancelable: true,
  328. view: window
  329. });
  330. subscribeButton.dispatchEvent(clickEvent);
  331. } else {
  332. console.error('Subscribe button not found');
  333. }
  334. },
  335. () => {
  336. const unsubscribeButton = document.querySelector(
  337. 'button[aria-label="Unsubscribe"].yt-spec-button-shape-next.yt-spec-button-shape-next--text.yt-spec-button-shape-next--call-to-action.yt-spec-button-shape-next--size-m'
  338. );
  339.  
  340. if (unsubscribeButton) {
  341. const clickEvent = new MouseEvent('click', {
  342. bubbles: true,
  343. cancelable: true,
  344. view: window
  345. });
  346. unsubscribeButton.dispatchEvent(clickEvent);
  347. } else {
  348. console.error('Unsubscribe button not found, creating it...');
  349.  
  350. const button = document.querySelector(
  351. 'button.yt-spec-button-shape-next.yt-spec-button-shape-next--tonal.yt-spec-button-shape-next--mono.yt-spec-button-shape-next--size-m.yt-spec-button-shape-next--icon-leading-trailing'
  352. );
  353. button.click();
  354.  
  355. const observerz = new MutationObserver((mutationsList) => {
  356. mutationsList.forEach((mutation) => {
  357. mutation.addedNodes.forEach((node) => {
  358. if (node.nodeType === Node.ELEMENT_NODE && node.textContent === 'Unsubscribe') {
  359. node.click();
  360. observerz.disconnect();
  361. }
  362. });
  363. });
  364. });
  365.  
  366. observerz.observe(document.body, {
  367. childList: true,
  368. subtree: true
  369. });
  370.  
  371. console.log("Step 1 success!");
  372.  
  373. function wait50ms() {
  374. return new Promise(resolve => setTimeout(resolve, 50));
  375. }
  376.  
  377. wait50ms().then(() => {
  378. const cancelButton = document.querySelector(
  379. 'button.yt-spec-button-shape-next.yt-spec-button-shape-next--text.yt-spec-button-shape-next--mono.yt-spec-button-shape-next--size-m[aria-label="Cancel"]'
  380. );
  381.  
  382. if (cancelButton) {
  383. cancelButton.click();
  384. console.log("Unsubscribe button created!");
  385.  
  386. if (unsubscribeButton) {
  387. const clickEvent = new MouseEvent('click', {
  388. bubbles: true,
  389. cancelable: true,
  390. view: window
  391. });
  392. unsubscribeButton.dispatchEvent(clickEvent);
  393. } else {
  394. console.error('Failed to find unsubscribe button after cancel.');
  395. }
  396. }
  397. });
  398. }
  399. }
  400. );
  401.  
  402. createToggleButton('Paused', // pausing, self explainitory
  403. () => {
  404. const video = document.querySelector('video');
  405. video.pause();
  406. },
  407. () => {
  408. const video = document.querySelector('video');
  409. video.play();
  410. }
  411. );
  412. // fake likes, reminder do not change the likes first letter to be a character, it breaks the script
  413. function setFakeLikes(value) {
  414. const likesElement = document.querySelectorAll('div[class="yt-spec-button-shape-next__button-text-content"]');
  415.  
  416. likesElement.forEach(element => {
  417. const textContent = element.textContent.trim();
  418.  
  419. if (textContent && !isNaN(textContent[0])) {
  420. element.textContent = value;
  421. }
  422. });
  423. }
  424. // playbackspeed
  425. function setPlaybackSpeed(value) {
  426. const video = document.querySelector("video");
  427. video.playbackRate = value;
  428. }
  429. // set volume
  430. let audioContext;
  431. let gainNode;
  432.  
  433. function setVolume(value) {
  434. const vid5 = document.querySelector("video");
  435. if (!audioContext) {
  436. audioContext = new AudioContext();
  437. }
  438.  
  439. if (!gainNode) {
  440. gainNode = audioContext.createGain();
  441. const source = audioContext.createMediaElementSource(vid5);
  442. source.connect(gainNode);
  443. gainNode.connect(audioContext.destination);
  444. }
  445. gainNode.gain.value = value;
  446. }
  447. // desc
  448. function setDesc(value) {
  449. // Select all the spans that contain the relevant links and styles
  450. const elements = document.querySelectorAll(
  451. 'span.yt-core-attributed-string--link-inherit-color[dir="auto"][style*="color: rgb"]'
  452. );
  453.  
  454. // Iterate through the found elements
  455. elements.forEach((element) => {
  456. element.textContent = value;
  457. const link = element.querySelector('a');
  458. link.remove();
  459. });
  460. }
  461. //fake subs
  462. function setFakeSubs(value) {
  463. const subsElement = document.getElementById('owner-sub-count');
  464. if (subsElement) subsElement.textContent = value;
  465. }
  466.  
  467. //fake pin
  468. function setPinner(value) {
  469. const pinner = document.querySelector('yt-formatted-string#label.style-scope.ytd-pinned-comment-badge-renderer');
  470.  
  471. if (pinner && pinner.id === 'label') {
  472. pinner.textContent = value;
  473. } else {
  474. console.log('404');
  475. }
  476.  
  477. }
  478. // fake views
  479. function setFakeViews(value) {
  480. const viewsElement = document.getElementsByClassName('style-scope yt-formatted-string bold');
  481. if (viewsElement) viewsElement[0].textContent = value;
  482. }
  483. // search placeholder
  484. function setSearch(value) {
  485. const searchInput = document.querySelector('.ytSearchboxComponentInput.yt-searchbox-input.title');
  486. if (searchInput) {
  487. searchInput.placeholder = value;
  488. }
  489. }
  490. // width
  491. function setWidth(value) {
  492. const width = document.querySelector('video');
  493. width.style.width = value + 'px';
  494. }
  495. //height
  496. function setHeight(value) {
  497. const height = document.querySelector('video');
  498. height.style.height = value + 'px';
  499. }
  500. //duration
  501. function setDuration(value) {
  502. const duration = document.getElementsByClassName("ytp-time-duration");
  503. const duration2 = document.querySelector('span[class="ytp-time-duration"]')
  504. duration.value = value;
  505. duration.textContent = value;
  506. duration2.textContent = value;
  507. }
  508. //Time watched
  509. function setTime(value) {
  510. const time = document.querySelector("video");
  511. time.currentTime = value;
  512. }
  513. //fake name
  514. function setFakeName(value) {
  515. const nameElement = document.querySelector('a.yt-simple-endpoint.style-scope.yt-formatted-string[spellcheck="false"]');
  516.  
  517. if (nameElement) {
  518. nameElement.textContent = value;
  519. } else {
  520. console.log("Element not found");
  521. }
  522. }
  523. // title changer
  524. function setChangeTitle(value) {
  525. const titleElement = document.querySelector('h1.style-scope.ytd-watch-metadata yt-formatted-string');
  526.  
  527. if (titleElement) {
  528. titleElement.textContent = value;
  529. }
  530. }
  531.  
  532. inputs.forEach(createInputButton);
  533. // dragging script
  534. let isDragging = false;
  535. let offsetX, offsetY;
  536. // minimizing
  537. container.addEventListener('mousedown', (e) => {
  538. if (e.target.tagName !== 'INPUT' && e.target.tagName !== 'BUTTON') {
  539. isDragging = true;
  540. offsetX = e.clientX - container.getBoundingClientRect().left;
  541. offsetY = e.clientY - container.getBoundingClientRect().top;
  542. }
  543. });
  544.  
  545. document.addEventListener('mousemove', (e) => {
  546. if (isDragging) {
  547. container.style.left = `${e.clientX - offsetX}px`;
  548. container.style.top = `${e.clientY - offsetY}px`;
  549. }
  550. });
  551.  
  552. document.addEventListener('mouseup', () => {
  553. isDragging = false;
  554. });
  555.  
  556. let isVisible = true;
  557. document.addEventListener('keydown', (e) => {
  558. if (e.key === 'Insert') {
  559. if (isVisible) {
  560. container.style.display = 'none';
  561. } else {
  562. container.style.display = 'block';
  563. }
  564. isVisible = !isVisible;
  565. }
  566. });
  567.  
  568. // made by theyhoppingonme on discord
  569. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址