Skip to content

Commit

Permalink
Skip metadata parsing when ad is playing
Browse files Browse the repository at this point in the history
  • Loading branch information
jiri-janousek committed Sep 27, 2020
1 parent 759a832 commit e749740
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ YouTube Music Change Log

* Don't depend on the button title to distinguish playing and paused states. Issue: tiliado/nuvolaruntime#526
* Mask as Safari to work around Google sign-in issues. Issue: tiliado/nuvolaruntime#575
* Remove broken code to skip ads. Purchasing YouTube Music Premium is better option.
* Skip metadata parsing when ad is playing.

1.3 - October 14th, 2018
------------------------
Expand Down
24 changes: 16 additions & 8 deletions integrate.js
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:
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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')
}
Expand Down Expand Up @@ -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)

0 comments on commit e749740

Please sign in to comment.