Subscribe For More Content! ► http://bit.ly/2nrb7a5
10 Types of Instagram Guitarists
// response.text())
.then(html => {
let parser = new DOMParser();
let doc = parser.parseFromString(html, 'text/html');
// Look for ANY iframe containing youtube or youtu.be
let ytIframe = doc.querySelector('iframe[src*="youtube.com"], iframe[src*="youtube-nocookie.com"], iframe[src*="youtu.be"]');
let videoId = null;
if (ytIframe) {
let src = ytIframe.src;
try {
let url = new URL(src.startsWith('//') ? 'https:' + src : src);
if (url.pathname.includes('/embed/')) {
videoId = url.pathname.split('/embed/')[1].split('?')[0];
} else if (url.pathname.includes('/v/')) {
videoId = url.pathname.split('/v/')[1].split('?')[0];
} else if (url.searchParams.has('v')) {
videoId = url.searchParams.get('v');
}
} catch(e) {
let match = src.match(/([a-zA-Z0-9_-]{11})/);
if (match) videoId = match[1];
}
}
if (videoId) {
videoCache[postUrl] = videoId; // Save it to the cache
applyThumb(thumb, videoId);
} else {
// It's a post with no video. Let Blogger keep the original image.
thumb.dataset.novideo = "true";
}
})
.catch(err => console.error("Fetch error:", err));
}
// 1. The Guard: Watches for Blogger trying to sneak the proxy link back in
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.type === 'attributes' && mutation.attributeName === 'style') {
let target = mutation.target;
let currentBg = target.style.backgroundImage || "";
// If Blogger just injected the proxy, and we know this post has a video... intercept it!
if (currentBg.includes("blogger_img_proxy") && target.dataset.novideo !== "true") {
processThumbnail(target);
}
}
});
});
// 2. Start guarding all thumbnails on the page
function attachGuards() {
document.querySelectorAll('.snippet-thumbnail').forEach(thumb => {
if (!thumb.dataset.guarded) {
// Tell the observer to watch this specific box's "style" attribute
observer.observe(thumb, { attributes: true, attributeFilter: ['style'] });
thumb.dataset.guarded = "true";
// Trigger the first check immediately in case Blogger already set a broken image
let currentBg = thumb.style.backgroundImage || "";
if (currentBg.includes("blogger_img_proxy")) {
processThumbnail(thumb);
}
}
});
}
// Run immediately and keep checking for new boxes (like infinite scrolling)
attachGuards();
setInterval(attachGuards, 1500);
});
//]]>