Skip to content

Instantly share code, notes, and snippets.

@mateuszdw
Last active April 19, 2021 06:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mateuszdw/0302b0b78045441267ea3847b0a6df57 to your computer and use it in GitHub Desktop.
Save mateuszdw/0302b0b78045441267ea3847b0a6df57 to your computer and use it in GitHub Desktop.
getArtistName(currentTabId, callback) {
chrome.tabs.executeScript(
currentTabId,
{ code: `document.querySelector('.now-playing span a[href^="/artist/"]').innerText` },
callback
);
}
getSongName(currentTabId, callback) {
chrome.tabs.executeScript(
currentTabId,
{ code: `document.querySelector('.now-playing span a[href^="/album/"]').innerText` },
callback
);
}
clickNext(currentTabId, callback) {
let query = '#main .Root__now-playing-bar .now-playing-bar__center .player-controls__buttons button.spoticon-skip-forward-16';
chrome.tabs.executeScript(
currentTabId,
{ code: `document.querySelector('${query}').click()` },
callback
);
}
clickPrev(currentTabId, callback) {
let query = '#main .Root__now-playing-bar .now-playing-bar__center .player-controls__buttons button.spoticon-skip-back-16';
chrome.tabs.executeScript(
currentTabId,
{ code: `document.querySelector('${query}').click()` },
callback
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment