Youtube AutoLike

Script to automatically like Youtube Videos Opened in Browser

  1. // ==UserScript==
  2. // @name Youtube AutoLike
  3. // @homepageURL https://github.com/Koalapvh13/Tampermonkey-Scripts
  4. // @namespace http://tampermonkey.net/
  5. // @version 0.1
  6. // @description Script to automatically like Youtube Videos Opened in Browser
  7. // @license MIT
  8. // @icon https://lh3.googleusercontent.com/zw07Qyfb7MnF8J9pZJ6eYheztKq1shP1j6tUqyDYZj6R60nNrrPrFZvC9k5JIe2m9t2GfQLbXg=w128-h128-e365-rj-sc0x00ffffff
  9. // @author Matheus Dias Vieira
  10. // @copyright 2020, Matheus Dias Vieira (https://github.com/Koalapvh13)
  11. // @match http*://*.youtube.com/watch?v=*
  12. // @include http*://*.youtube.com/*
  13. // @include http*://youtube.com/*
  14. // @include http*://*.youtu.be/*
  15. // @include http*://youtu.be/*
  16. // @run-at document-end
  17. // @grant none
  18. // ==/UserScript==
  19.  
  20. (function () {
  21. 'use strict';
  22.  
  23. const like = () => {
  24. const interval = setInterval(() => {
  25. const btnlike = document.querySelector("#top-level-buttons > ytd-toggle-button-renderer:nth-child(1)")
  26. if (btnlike) {
  27. clearInterval(interval)
  28. if (!btnlike.classList.contains("style-default-active")) {
  29. btnlike.click()
  30. }
  31. }
  32.  
  33. }, 1000)
  34. }
  35.  
  36. document.body.addEventListener("yt-navigate-finish", function (event) {
  37. if (window.location.pathname == "/watch") {
  38. console.log(window.location.href)
  39. console.log(window.location.pathname)
  40. like()
  41. }
  42.  
  43. });
  44.  
  45. })();