Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more ad URLs to skip. Ref #1599 (comment).
- Loading branch information
1 parent
160f40a
commit 631dd4c
Showing
1 changed file
with
14 additions
and
8 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
'use strict'; | ||
|
||
const adUrls = [ | ||
'utm_source=display', | ||
'ad.doubleclick.net', | ||
'spotify:playlist', | ||
'shrt.spotify.com' | ||
]; | ||
|
||
Connector.playerSelector = '.Root__now-playing-bar'; | ||
|
||
Connector.artistSelector = '.track-info__artists a'; | ||
|
@@ -20,15 +27,14 @@ Connector.isScrobblingAllowed = () => !isAdPlaying(); | |
|
||
Connector.isPodcast = () => artistUrlIncludes('/show/'); | ||
|
||
/* | ||
* When ad is playing, artist URL is like "https://shrt.spotify.com/XXX", | ||
* otherwise URL leads to: | ||
* a) an artist page https://open.spotify.com/artist/YYY; | ||
* b) a podcast page https://open.spotify.com/show/ZZZ. | ||
*/ | ||
|
||
function isAdPlaying() { | ||
return artistUrlIncludes('shrt.spotify.com'); | ||
for (const adUrl of adUrls) { | ||
if (artistUrlIncludes(adUrl)) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
alexesprit
Author
Member
|
||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
|
||
function artistUrlIncludes(str) { | ||
|
What about doing
$(Connector.artistSelector).attr('href')
outside the loop? is this an expensive operation?