Advertisement
Guest User

Gab Auto Scroll (Userscript)

a guest
Jul 16th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Gab Auto Scroll
  3. // @namespace    https://gab.com/spender
  4. // @version      0.1
  5. // @description  Automatically clicks "load more" when scrolling through Gab feeds
  6. // @author       @spender
  7. // @match        https://gab.com/*
  8. // @grant        none
  9. // ==/UserScript==
  10.  
  11. ;(function() {
  12.     "use strict"
  13.     let loading = false
  14.     window.addEventListener('scroll', function() {
  15.         if (loading) return
  16.         const { scrollHeight, clientHeight, scrollTop } = document.documentElement
  17.         if (scrollHeight < 3 * clientHeight + scrollTop) {
  18.             const button = document.querySelector("button.load-more")
  19.             const feed = document.querySelector(".item-list[role='feed']")
  20.             if (button && feed) {
  21.                 const observer = new MutationObserver(() => {
  22.                     observer.disconnect()
  23.                     loading = false
  24.                 })
  25.                 observer.observe(feed, { childList: true })
  26.                 button.click()
  27.                 loading = true
  28.             }
  29.         }
  30.     })
  31. })()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement