TikTok Autoscroll

Autoscroll videos on tiktok.

  1. // ==UserScript==
  2. // @name TikTok Autoscroll
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2.3
  5. // @description Autoscroll videos on tiktok.
  6. // @author @Masiosare
  7. // @match https://tiktok.com/*
  8. // @license GNU GPLv3
  9. // @match https://www.tiktok.com/*
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. 'use strict';
  15. let debug_enabled = false;
  16. let time_after_scroll = 0.5; //seconds
  17.  
  18. function scrollTo(e) {
  19.  
  20. while(e.tagName.toLowerCase() !== "body") {
  21. e = e.parentElement;
  22. if(e.className.includes("DivItemContainer")){
  23. err("Scrolling to")
  24. err(e.nextSibling)
  25.  
  26. e.nextSibling.scrollIntoView({behavior: "smooth", block: "start", inline: "nearest"});
  27. break;
  28. }
  29. }
  30. }
  31. err("Before event");
  32. document.addEventListener("DOMNodeInserted", function (e) {
  33.  
  34. if (e.target && e.target.className && e.target.className.toString().includes("DivBasicPlayerWrapper")) {
  35. err("Found Video")
  36.  
  37. let video = e.target.getElementsByTagName("video")[0]
  38. video.loop = false;
  39. video.muted = false;
  40. video.controls = true;
  41.  
  42. video.addEventListener('ended', function (v) {
  43. err("Video ended");
  44. err(v);
  45.  
  46. v.target.pause();
  47. err("Scrolling in " + time_after_scroll * 1000);
  48. setTimeout(function () {
  49.  
  50. scrollTo(v.target)
  51. }, time_after_scroll * 1000);
  52. }, false);
  53.  
  54.  
  55. }
  56.  
  57. }, false);
  58.  
  59. function err(e){
  60. if (debug_enabled === true ) {
  61. if (typeof e == "string"){
  62. console.log("TT Autoscroll: "+ e)
  63. } else {
  64. console.log(e)
  65. }
  66. }
  67. }
  68.  
  69. })();

QingJ © 2025

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