This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Check Youtube thumbnails link to videos before adding overlay (#402)

- fixes #356
  • Loading branch information...
danrr authored and meandavejustice committed Oct 7, 2016
1 parent ab1e3da commit aaec5c5914473ccf56a8f789abf747cd27c7e78c
Showing with 12 additions and 7 deletions.
  1. +12 −7 data/icon-overlay.js
View
@@ -66,17 +66,22 @@ function ytEmbedChecks() {
function ytHomePageHandler(el) {
if (el.classList.contains('minvid__overlay__wrapper')) return;
const urlEl = el.querySelector('.yt-uix-sessionlink');
if (!urlEl || !urlEl.getAttribute('href')) return;
const url = urlEl.getAttribute('href');
if (!url.startsWith('/watch')) return;
el.classList.add('minvid__overlay__wrapper');
const tmp = getTemplate();
tmp.addEventListener('click', function(ev) {
evNoop(ev);
const urlEl = el.querySelector('.yt-uix-sessionlink');
if (urlEl && urlEl.getAttribute('href')) {
self.port.emit('launch', {
url: 'https://youtube.com' + urlEl.getAttribute('href'),
domain: 'youtube.com'
});
} else console.error('Error parsing url from YT home page', el); // eslint-disable-line no-console
self.port.emit('launch', {
url: 'https://youtube.com' + url,
domain: 'youtube.com'
});
});
el.appendChild(tmp);
}

0 comments on commit aaec5c5

Please sign in to comment.