-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Skip metadata parsing when ad is playing
- Loading branch information
1 parent
759a832
commit e749740
Showing
2 changed files
with
18 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
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,5 @@ | ||
/* | ||
* Copyright 2018 Jiří Janoušek <[email protected]> | ||
* Copyright 2018-2020 Jiří Janoušek <[email protected]> | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
|
@@ -74,15 +74,19 @@ | |
// Extract data from the web page | ||
WebApp.update = function () { | ||
var elms = this._getElements() | ||
if (elms.skipAd) { | ||
if (elms.skipAd.parentNode.style.display !== 'none') { | ||
Nuvola.clickOnElement(elms.skipAd) | ||
if (this.isAdPlaying()) { | ||
var track = { | ||
artist: null, | ||
album: null, | ||
artLocation: null, | ||
rating: null, | ||
length: null | ||
} | ||
player.setTrack(track) | ||
} else { | ||
var track = { | ||
track = { | ||
title: Nuvola.queryText('.middle-controls .title'), | ||
artist: Nuvola.queryText('.middle-controls .byline', value => value.split('•')[0]), | ||
album: null, | ||
artist: Nuvola.queryText('.middle-controls .byline', value => value.split('•')[0].trim() || null), | ||
artLocation: Nuvola.queryAttribute('.middle-controls img', 'src'), | ||
rating: null | ||
} | ||
|
@@ -143,7 +147,6 @@ | |
progressbar: document.querySelector('#progress-bar #sliderBar'), | ||
volumebar: document.querySelector('#volume-slider #sliderBar'), | ||
expandingMenu: document.querySelector('#right-controls #expanding-menu'), | ||
skipAd: document.querySelector('button.videoAdUiSkipButton'), | ||
like: document.querySelector('.middle-controls-buttons .like'), | ||
dislike: document.querySelector('.middle-controls-buttons .dislike') | ||
} | ||
|
@@ -272,5 +275,10 @@ | |
entries.push(['bool', THUMB_NEVER_TOGGLES, _('Treat thumbs up or down selection as a one-way switch,\nnot a toggle.')]) | ||
} | ||
|
||
WebApp.isAdPlaying = function () { | ||
var elm = document.querySelector('.middle-controls .advertisement') | ||
return !!(elm && !elm.hidden) | ||
} | ||
|
||
WebApp.start() | ||
})(this) // function(Nuvola) |