Created
March 1, 2020 12:05
-
-
Save prs-watch/ee7653409107225dff6e535467e77016 to your computer and use it in GitHub Desktop.
Expand MLB.com Prospect List without clicking "Load More" button
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name MLB.com Prospect List Expander | |
| // @namespace http://tampermonkey.net/ | |
| // @version 0.1 | |
| // @description Expand MLB.com Prospect List without clicking "Load More" button. | |
| // @author prs-watch | |
| // @match https://www.mlb.com/prospects/* | |
| // @grant none | |
| // ==/UserScript== | |
| window.onload = () => { | |
| const load = () => { | |
| const container = document.getElementsByClassName("load-more__container")[0] | |
| const buttons = container.getElementsByTagName("button") | |
| while(buttons.length != 0) { | |
| buttons[0].click() | |
| } | |
| } | |
| load() | |
| const target = document.body | |
| const observer = new MutationObserver(records => { | |
| load() | |
| }) | |
| observer.observe(target, { | |
| attributes: true | |
| }) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment