Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed the script #145

Open
SethWiiPlaza opened this issue Dec 1, 2023 · 3 comments
Open

Fixed the script #145

SethWiiPlaza opened this issue Dec 1, 2023 · 3 comments

Comments

@SethWiiPlaza
Copy link

SethWiiPlaza commented Dec 1, 2023

https://github.com/SethWiiPlaza/YT-AutoLike/releases/tag/Release

5 second delay before like (Google Chrome only)

use the 'Run Javascript' Chrome Extension to execute script (copy + paste script)

or 'Custom JavaScript for Websites 2' to inject

// code by Seth@WiiPlaza
function clickLikeButton() {
  const likeButtonSelector =
    '#top-level-buttons-computed > segmented-like-dislike-button-view-model > yt-smartimation > div > div > like-button-view-model > toggle-button-view-model > button > yt-touch-feedback-shape > div';

  // Function to click the like button
  function performClick() {
    const likeButton = document.querySelector(likeButtonSelector);

    if (likeButton) {
      likeButton.click();
      console.log('Like button clicked');
    } else {
      console.log('Like button not found');
    }
  }

  // Wait for 5 seconds before executing the rest of the code
  setTimeout(performClick, 5000); // 5000 milliseconds = 5 seconds

  // Monitor changes in the video title
  let currentTitle = getTitle();

  function getTitle() {
    const titleElement = document.querySelector("#title > h1 > yt-formatted-string");
    return titleElement ? titleElement.textContent : null;
  }

  function checkTitleChange() {
    const newTitle = getTitle();

    if (newTitle !== currentTitle) {
      // Video title has changed, re-run the script
      console.log('Video title has changed, re-running the script...');
      performClick();
      // Update the current title
      currentTitle = newTitle;
    }

    // Check for title changes every 1 second
    setTimeout(checkTitleChange, 1000); // 1000 milliseconds = 1 second
  }

  checkTitleChange();
}

// Call the function to click the like button
clickLikeButton();

image

@Nicodemus111
Copy link

yours was liking twice and i wanted it in a userscript so i changed it a bit for myself:

// @name         youtube auto like
// @version      1.1
// @description  👍
// @author       Seth@WiiPlaza
// @match        https://www.youtube.com/*
// @grant        none
// ==/UserScript==
function clickLikeButton() {
  const likeButtonSelector =
    '#top-level-buttons-computed > segmented-like-dislike-button-view-model > yt-smartimation > div > div > like-button-view-model > toggle-button-view-model > button > yt-touch-feedback-shape > div';

  // Function to click the like button
  function performClick() {
    const likeButton = document.querySelector(likeButtonSelector);

    if (likeButton) {
      likeButton.click();
      console.log('Like button clicked');
    } else {
      console.log('Like button not found');
    }
  }

  // Wait for 5 seconds before executing the rest of the code
  setTimeout(performClick, 10000); // 5000 milliseconds = 5 seconds

  // Monitor changes in the video title
  let currentTitle = getTitle();

  function getTitle() {
    const titleElement = document.querySelector("#title > h1 > yt-formatted-string");
    return titleElement ? titleElement.textContent : null;
  }

  function checkTitleChange() {
    const newTitle = getTitle();

    if (newTitle !== currentTitle) {
      // Video title has changed, re-run the script
      console.log('Video title has changed, re-running the script...');
      // Update the current title
      currentTitle = newTitle;
    }

    // Check for title changes every 1 second
    setTimeout(checkTitleChange, 1000); // 1000 milliseconds = 1 second
  }

  checkTitleChange();
}

// Call the function to click the like button
clickLikeButton();```

@Hom3r86
Copy link

Hom3r86 commented Dec 4, 2023

yours was liking twice and i wanted it in a userscript so i changed it a bit for myself:

// @name         youtube auto like
// @version      1.1
// @description  👍
// @author       Seth@WiiPlaza
// @match        https://www.youtube.com/*
// @grant        none
// ==/UserScript==
function clickLikeButton() {
  const likeButtonSelector =
    '#top-level-buttons-computed > segmented-like-dislike-button-view-model > yt-smartimation > div > div > like-button-view-model > toggle-button-view-model > button > yt-touch-feedback-shape > div';

  // Function to click the like button
  function performClick() {
    const likeButton = document.querySelector(likeButtonSelector);

    if (likeButton) {
      likeButton.click();
      console.log('Like button clicked');
    } else {
      console.log('Like button not found');
    }
  }

  // Wait for 5 seconds before executing the rest of the code
  setTimeout(performClick, 10000); // 5000 milliseconds = 5 seconds

  // Monitor changes in the video title
  let currentTitle = getTitle();

  function getTitle() {
    const titleElement = document.querySelector("#title > h1 > yt-formatted-string");
    return titleElement ? titleElement.textContent : null;
  }

  function checkTitleChange() {
    const newTitle = getTitle();

    if (newTitle !== currentTitle) {
      // Video title has changed, re-run the script
      console.log('Video title has changed, re-running the script...');
      // Update the current title
      currentTitle = newTitle;
    }

    // Check for title changes every 1 second
    setTimeout(checkTitleChange, 1000); // 1000 milliseconds = 1 second
  }

  checkTitleChange();
}

// Call the function to click the like button
clickLikeButton();```

tried to install it in tampermonkey but i get an error

@Enixmage
Copy link

Enixmage commented Dec 5, 2023

Remove the lines

// Wait for 5 seconds before executing the rest of the code
setTimeout(performClick, 5000); // 5000 milliseconds = 5 seconds

and it seems to work till a proper fix at least.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants