MCPcopy Create free account
hub / github.com/Useful-Scripts-Extension/useful-script / animate

Function animate

scripts/spotify_downloadButton.js:76–109  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

74 }
75
76 function animate() {
77 const tracks = document.querySelectorAll(
78 '[data-testid="tracklist-row"]'
79 );
80 for (const track of tracks) {
81 if (!track.hasButton) {
82 addButton(track).onclick = async function () {
83 const btn = track.querySelector('[data-testid="more-button"]');
84 btn.click();
85 await sleep(10);
86
87 const highlight = document
88 .querySelector('#context-menu a[href*="highlight"]')
89 .href.match(/highlight=(.+)/)[1];
90 document.dispatchEvent(new MouseEvent("mousedown"));
91
92 const url =
93 "https://open." +
94 highlight.replace(":", ".com/").replace(":", "/");
95 download(url);
96 };
97 }
98 }
99
100 const actionBarRow = document.querySelector(
101 '[data-testid="action-bar-row"]:last-of-type'
102 );
103
104 if (actionBarRow && !actionBarRow.hasButton) {
105 addButton(actionBarRow).onclick = function () {
106 download(window.location.href);
107 };
108 }
109 }
110
111 function download(link) {
112 window.open("https://spotify-downloader.com/?link=" + link, "_blank");

Callers

nothing calls this directly

Calls 5

addButtonFunction · 0.85
clickMethod · 0.80
replaceMethod · 0.80
sleepFunction · 0.70
downloadFunction · 0.70

Tested by

no test coverage detected