- // ==UserScript==
- // @name Ans youtube GUI (ADBLOCKER, VOLUME CHANGER, 15+ MODS)
- // @name:fi Anin Youtube käyttöliittymä (MAINOSESTÄJÄ, ÄÄNITASON VAIHTAJA, 15+ MODIFIKAATIOTA)
- // @namespace http://tampermonkey.net/
- // @version 1.1.3
- // @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
- // @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.
- // @author @theyhoppingonme on discord
- // @match https://www.youtube.com/*
- // @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com
- // @grant none
- // ==/UserScript==
-
- (function() {
- 'use strict';
- //patch logs:
- // V1.0.0: GUI released
- // V1.0.1: Adblock
- // V1.0.2: Just a simple name change and patch logs
- // V1.0.3 Added more unsubscribe button filters
- // V1.0.4 New GUI name
- // V1.0.5 Added desc changer
- // V1.0.6 Added pinned comment name changer
- // V1.0.7 Added volume changer (bass boost epic), video width changer, video height changer, video duration changer, video time watched changer
- // 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!
- // V1.0.9 Adblock is ACTUALLY fixed sorry for the inconvinience it was broken a bit
- // V1.1.0 Added change search placeholder
- // V1.1.1 Fixed Description Filtering
- // V1.1.2 new epic UI
- // V1.1.3 Fixed the video height and width changing, made gui look a bit better
-
- function isYouTubeShort() {
- const currentURL = window.location.href;
- if (currentURL.includes('youtube.com/shorts/')) {
- 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.');
- }
- }
- isYouTubeShort();
-
- function isLiveChat() {
- const currentURL = window.location.href;
- if (currentURL.includes('youtube.com/live_chat')) {
- return;
- }
- }
- isLiveChat();
- const style = document.createElement('style'); // style for the menu
- style.textContent = `
- .container {
- text-align: center;
- width: 90%;
- max-width: 800px;
- padding: 20px 30px;
- background-color: #222;
- border-radius: 12px;
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
- font-family: 'Arial', sans-serif;
- color: white;
- position: fixed;
- top: 20px;
- right: 20px;
- z-index: 10000;
- transition: box-shadow 0.3s ease-in-out, background-color 0.3s ease;
- }
- button {
- background-color: #444;
- border: none;
- color: white;
- font-size: 11px;
- padding: 6px 9px;
- margin: 5px;
- cursor: pointer;
- transition: background-color 0.2s ease, transform 0.2s ease;
- }
- button:hover {
- background-color: #6B3EFF;
- transform: scale(1.05);
- }
- .close-button, .minimize-button {
- position: absolute;
- top: 12px;
- background-color: transparent;
- border: none;
- color: white;
- font-size: 20px;
- cursor: pointer;
- transition: color 0.2s ease;
- }
- .close-button {
- right: 40px;
- }
- .minimize-button {
- right: 0px;
- }
- .close-button:hover, .minimize-button:hover {
- color: #6B3EFF;
- }
- `;
- document.head.appendChild(style);
- const container = document.createElement('div'); //Creating the menu
- container.className = 'container';
- document.body.appendChild(container);
-
- const title = document.createElement('h1'); // menu name
- const nameElement = document.getElementById("account-name");
- const name = nameElement ? nameElement.textContent.trim() : "Guest";
- title.textContent = "Ans Youtube GUI V1.1.3";
- container.appendChild(title);
-
- const closeButton = document.createElement('button'); // close button
- closeButton.className = 'close-button';
- closeButton.textContent = 'X';
- container.appendChild(closeButton);
- closeButton.addEventListener('click', () => {
- container.style.display = 'none';
- });
- // minimize menu (button not shown, press insert to minimize)
- const minimizeButton = document.createElement('button');
- minimizeButton.className = 'minimize-button';
- minimizeButton.textContent = '';
- container.appendChild(minimizeButton);
- minimizeButton.addEventListener('click', () => {
- container.style.display = 'none';
- });
-
- const inputs = [ // inputs
- { placeholder: 'Fake likes', action: setFakeLikes },
- { placeholder: 'Fake subs', action: setFakeSubs },
- { placeholder: 'Fake views', action: setFakeViews },
- { placeholder: 'Change Title', action: setChangeTitle },
- { placeholder: 'Change ChannelName', action: setFakeName },
- { placeholder: 'Change Playbackspeed', action: setPlaybackSpeed },
- { placeholder: 'Fake Description', action: setDesc },
- { placeholder: 'Fake CommentPinner', action: setPinner },
- { placeholder: 'Change volume', action: setVolume },
- { placeholder: 'Video Height', action: setHeight },
- { placeholder: 'Video Width', action: setWidth },
- { placeholder: 'Video Duration', action: setDuration },
- { placeholder: 'Set TimeWatched (seconds)', action: setTime },
- { placeholder: 'Set SearchPlaceholder', action: setSearch }
- ];
-
- function createInputButton(inputConfig) { // creating input buttons
- const input = document.createElement('input');
- input.type = 'text';
- input.placeholder = inputConfig.placeholder;
- container.appendChild(input);
-
- const button = document.createElement('button');
- button.textContent = `Set ${inputConfig.placeholder.split(' ')[1]}`;
- container.appendChild(button);
-
- button.addEventListener('click', () => {
- inputConfig.action(input.value);
- });
- }
-
- function createToggleButton(label, enableFunction, disableFunction) { // creating toggles
- const toggleContainer = document.createElement('div');
- toggleContainer.style.marginTop = '10px';
- container.appendChild(toggleContainer);
-
- const labelElement = document.createElement('span');
- labelElement.textContent = label;
- labelElement.style.marginRight = '10px';
- toggleContainer.appendChild(labelElement);
-
- const toggleButton = document.createElement('button');
- toggleButton.textContent = 'OFF';
- toggleButton.style.padding = '5px 10px';
- toggleButton.style.cursor = 'pointer';
- toggleContainer.appendChild(toggleButton);
-
- let isToggled = false;
-
- toggleButton.addEventListener('click', () => {
- isToggled = !isToggled;
- toggleButton.textContent = isToggled ? 'ON' : 'OFF';
- toggleButton.style.backgroundColor = isToggled ? '#6B3EFF' : '';
-
- if (isToggled) {
- enableFunction();
- } else {
- disableFunction();
- }
- });
- }
-
- const Adblock = () => {
- const scrub = document.querySelector('.ytp-fine-scrubbing')
- const player = document.querySelector('#movie_player')
- const adyesno = player.classList.contains('ad-showing')
- const vid = player.querySelector('video.html5-main-video')
- if (adyesno) {
- const skip = document.querySelector(`
- .ytp-skip-ad-button,
- .ytp-ad-skip-button,
- .ytp-ad-skip-button-modern,
- .ytp-ad-survey-answer-button
- `)
- if (skip) {
- skip.click()
- skip.remove()
- }
- else if (vid && vid.src) {
- vid.currentTime = 9999999999;
- }
- }
- const adSelectors = [
- '.ytp-ad-module',
- '.ytp-ad-text',
- '.ad-interrupting',
- '.video-ads',
- '.ytp-ad-image-overlay'
- ];
-
- const links = [
- 'about:blank'
- ];
-
- const skipButton = document.querySelector('.ytp-ad-skip-button');
- if (skipButton) skipButton.click();
-
- adSelectors.forEach(selector => {
- document.querySelectorAll(selector).forEach(ad => {
- ad.currentTime = ad.duration;
- });
- });
-
- function checkAndSkipAd() {
- const adBadge = document.querySelector('.ad-simple-attributed-string.ytp-ad-badge__text#ad-simple-attributed-string\\:a[aria-label="Sponsored"]');
-
- if (adBadge) {
- const vid = document.querySelector('video');
- if (vid) {
- vid.currentTime = 9489278134234324323424234;
- console.log('Ad detected and ad skipped.');
- }
- }
- }
-
- const observer = new MutationObserver(() => {
- checkAndSkipAd();
- });
-
- observer.observe(document.body, {
- childList: true,
- subtree: true,
- });
-
- checkAndSkipAd();
-
- };
-
-
-
- const reenableAds = () => {
- const skipButton = document.querySelector('.ytp-ad-skip-button');
- if (skipButton) skipButton.style.display = 'block';
-
- const overlayAd = document.querySelector('.ytp-ad-overlay-slot');
- if (overlayAd) overlayAd.style.display = 'block';
-
- const bannerAd = document.querySelector('.ytp-ce-element');
- if (bannerAd) bannerAd.style.display = 'block';
-
- const adFrame = document.querySelector('iframe[src*="ads"]');
- if (adFrame) adFrame.style.display = 'block';
-
- const adSelectors = [
- '.ytp-ad-player-overlay',
- '.ytp-ad-module',
- '.ytp-ad-text',
- '.ad-interrupting',
- '.video-ads',
- '.ytp-ad-image-overlay'
- ];
-
- adSelectors.forEach(selector => {
- document.querySelectorAll(selector).forEach(ad => {
- ad.style.display = 'block';
- });
- });
- const originalFetch = window.fetch;
- window.fetch = originalFetch;
-
- const originalXhrOpen = XMLHttpRequest.prototype.open;
- XMLHttpRequest.prototype.open = originalXhrOpen;
- };
-
- createToggleButton('Toggle YouTube Ad Blocker', Adblock, reenableAds);
- // ad block
-
- createToggleButton('Toggle Mute', // mute button, emulates the M key press
- () => {
- const keyEvent = new KeyboardEvent('keydown', {
- key: 'm',
- code: 'KeyM',
- keyCode: 77,
- which: 77,
- bubbles: true,
- cancelable: true
- });
- document.dispatchEvent(keyEvent);
- },
- () => {
- const keyEvent = new KeyboardEvent('keydown', {
- key: 'm',
- code: 'KeyM',
- keyCode: 77,
- which: 77,
- bubbles: true,
- cancelable: true
- });
- document.dispatchEvent(keyEvent);
- }
- );
-
- createToggleButton(
- 'Toggle subscription',
- () => {
- 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');
-
- if (subscribeButton) {
- const clickEvent = new MouseEvent('click', {
- bubbles: true,
- cancelable: true,
- view: window
- });
- subscribeButton.dispatchEvent(clickEvent);
- } else {
- console.error('Subscribe button not found');
- }
- },
- () => {
- const unsubscribeButton = document.querySelector(
- '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'
- );
-
- if (unsubscribeButton) {
- const clickEvent = new MouseEvent('click', {
- bubbles: true,
- cancelable: true,
- view: window
- });
- unsubscribeButton.dispatchEvent(clickEvent);
- } else {
- console.error('Unsubscribe button not found, creating it...');
-
- const button = document.querySelector(
- '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'
- );
- button.click();
-
- const observerz = new MutationObserver((mutationsList) => {
- mutationsList.forEach((mutation) => {
- mutation.addedNodes.forEach((node) => {
- if (node.nodeType === Node.ELEMENT_NODE && node.textContent === 'Unsubscribe') {
- node.click();
- observerz.disconnect();
- }
- });
- });
- });
-
- observerz.observe(document.body, {
- childList: true,
- subtree: true
- });
-
- console.log("Step 1 success!");
-
- function wait50ms() {
- return new Promise(resolve => setTimeout(resolve, 50));
- }
-
- wait50ms().then(() => {
- const cancelButton = document.querySelector(
- '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"]'
- );
-
- if (cancelButton) {
- cancelButton.click();
- console.log("Unsubscribe button created!");
-
- if (unsubscribeButton) {
- const clickEvent = new MouseEvent('click', {
- bubbles: true,
- cancelable: true,
- view: window
- });
- unsubscribeButton.dispatchEvent(clickEvent);
- } else {
- console.error('Failed to find unsubscribe button after cancel.');
- }
- }
- });
- }
- }
- );
-
- createToggleButton('Paused', // pausing, self explainitory
- () => {
- const video = document.querySelector('video');
- video.pause();
- },
- () => {
- const video = document.querySelector('video');
- video.play();
- }
- );
- // fake likes, reminder do not change the likes first letter to be a character, it breaks the script
- function setFakeLikes(value) {
- const likesElement = document.querySelectorAll('div[class="yt-spec-button-shape-next__button-text-content"]');
-
- likesElement.forEach(element => {
- const textContent = element.textContent.trim();
-
- if (textContent && !isNaN(textContent[0])) {
- element.textContent = value;
- }
- });
- }
- // playbackspeed
- function setPlaybackSpeed(value) {
- const video = document.querySelector("video");
- video.playbackRate = value;
- }
- // set volume
- let audioContext;
- let gainNode;
-
- function setVolume(value) {
- const vid5 = document.querySelector("video");
- if (!audioContext) {
- audioContext = new AudioContext();
- }
-
- if (!gainNode) {
- gainNode = audioContext.createGain();
- const source = audioContext.createMediaElementSource(vid5);
- source.connect(gainNode);
- gainNode.connect(audioContext.destination);
- }
- gainNode.gain.value = value;
- }
- // desc
- function setDesc(value) {
- // Select all the spans that contain the relevant links and styles
- const elements = document.querySelectorAll(
- 'span.yt-core-attributed-string--link-inherit-color[dir="auto"][style*="color: rgb"]'
- );
-
- // Iterate through the found elements
- elements.forEach((element) => {
- element.textContent = value;
- const link = element.querySelector('a');
- link.remove();
- });
- }
- //fake subs
- function setFakeSubs(value) {
- const subsElement = document.getElementById('owner-sub-count');
- if (subsElement) subsElement.textContent = value;
- }
-
- //fake pin
- function setPinner(value) {
- const pinner = document.querySelector('yt-formatted-string#label.style-scope.ytd-pinned-comment-badge-renderer');
-
- if (pinner && pinner.id === 'label') {
- pinner.textContent = value;
- } else {
- console.log('404');
- }
-
- }
- // fake views
- function setFakeViews(value) {
- const viewsElement = document.getElementsByClassName('style-scope yt-formatted-string bold');
- if (viewsElement) viewsElement[0].textContent = value;
- }
- // search placeholder
- function setSearch(value) {
- const searchInput = document.querySelector('.ytSearchboxComponentInput.yt-searchbox-input.title');
- if (searchInput) {
- searchInput.placeholder = value;
- }
- }
- // width
- function setWidth(value) {
- const width = document.querySelector('video');
- width.style.width = value + 'px';
- }
- //height
- function setHeight(value) {
- const height = document.querySelector('video');
- height.style.height = value + 'px';
- }
- //duration
- function setDuration(value) {
- const duration = document.getElementsByClassName("ytp-time-duration");
- const duration2 = document.querySelector('span[class="ytp-time-duration"]')
- duration.value = value;
- duration.textContent = value;
- duration2.textContent = value;
- }
- //Time watched
- function setTime(value) {
- const time = document.querySelector("video");
- time.currentTime = value;
- }
- //fake name
- function setFakeName(value) {
- const nameElement = document.querySelector('a.yt-simple-endpoint.style-scope.yt-formatted-string[spellcheck="false"]');
-
- if (nameElement) {
- nameElement.textContent = value;
- } else {
- console.log("Element not found");
- }
- }
- // title changer
- function setChangeTitle(value) {
- const titleElement = document.querySelector('h1.style-scope.ytd-watch-metadata yt-formatted-string');
-
- if (titleElement) {
- titleElement.textContent = value;
- }
- }
-
- inputs.forEach(createInputButton);
- // dragging script
- let isDragging = false;
- let offsetX, offsetY;
- // minimizing
- container.addEventListener('mousedown', (e) => {
- if (e.target.tagName !== 'INPUT' && e.target.tagName !== 'BUTTON') {
- isDragging = true;
- offsetX = e.clientX - container.getBoundingClientRect().left;
- offsetY = e.clientY - container.getBoundingClientRect().top;
- }
- });
-
- document.addEventListener('mousemove', (e) => {
- if (isDragging) {
- container.style.left = `${e.clientX - offsetX}px`;
- container.style.top = `${e.clientY - offsetY}px`;
- }
- });
-
- document.addEventListener('mouseup', () => {
- isDragging = false;
- });
-
- let isVisible = true;
- document.addEventListener('keydown', (e) => {
- if (e.key === 'Insert') {
- if (isVisible) {
- container.style.display = 'none';
- } else {
- container.style.display = 'block';
- }
- isVisible = !isVisible;
- }
- });
-
- // made by theyhoppingonme on discord
- })();