Last active
August 2, 2022 02:02
-
-
Save camerican/5c4163db69f6146141e2f50a57442906 to your computer and use it in GitHub Desktop.
Top Shot Locking Tool to Select All Moments
This file contains 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
// About - This script enables you to Select All Top Shot moments from the https://nbatopshot.com/lock page | |
// At the time of writing, you had to select moments one by one, which is a pain in the arse | |
// You can alternatively use a version of this script that works with Chrome browser extension Tampermonkey: | |
// | |
// https://gist.github.com/camerican/aeee6f0ff6e3d43e419047365cb2e2dc | |
// | |
// The Tampermonkey version of this script at the link above adds "Select All" and "Deselect All" buttons | |
// to the NBA TopShot lock page, which makes use of the script more intuitive | |
// | |
// Author - Camerican 8/1/22 | |
// | |
// Warning - Generally don't ever execute scripts such as this in your browser unless you are certain you trust the code. | |
// Running malicous code in your browser could compromise your account or take undesired actions on your behalf! | |
// | |
// Instructions - If you wish to use this script, you can run the following steps | |
// | |
// To Prepare the Script: | |
// | |
// 1) Open Developer Tools in your Browser | |
// 2) Within the Developer console, paste this gist contents | |
// | |
// To Run the script copy/paste the following snippets into the console: | |
// | |
// To Select all: | |
// selectAllMoments(); | |
// | |
// To Select all after the 3rd moment in view: | |
// selectAllMoments(3); | |
// | |
// To Deselect all moments: | |
// deselectAllMoments(); | |
function selectAllMoments(startAfter) { | |
startAfter = startAfter || 0; | |
selectorWorker(startAfter, unselectedSelector); | |
} | |
function deselectAllMoments(startAfter) { | |
selectorWorker(startAfter, selectedSelector); | |
} | |
function selectorWorker(startAfter, selector) { | |
Array.from(document.querySelectorAll("button.YFXSP")) | |
.slice(startAfter) | |
.filter( function(el) { | |
return el.querySelector(selector); | |
}) | |
.forEach( function(el) { | |
el.click(); | |
}); | |
} | |
var selectedSelector = 'svg path[d="M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10Zm-.997-6 7.07-7.07-1.414-1.415-5.656 5.657-2.829-2.829-1.414 1.414L11.003 16Z"]'; | |
var unselectedSelector = 'svg path[d="M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10Zm0-2a8 8 0 1 0 0-16 8 8 0 0 0 0 16Z"]'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment