Skip to content

Instantly share code, notes, and snippets.

@blizzy78
Last active August 16, 2016 12:05
Show Gist options
  • Save blizzy78/bfc5dd50cd263a14fa14 to your computer and use it in GitHub Desktop.
Save blizzy78/bfc5dd50cd263a14fa14 to your computer and use it in GitHub Desktop.
Remove pre-video ads from golem.de
// ==UserScript==
// @name Remove Golem.de Pre-Video Ads
// @namespace http://blizzy.de/
// @version 1.0
// @description Removes pre-video ads from videos on golem.de
// @match http://*.golem.de/*
// @copyright 2014-2016, Maik Schreiber
// @require //code.jquery.com/jquery-3.1.0.min.js
// @grant none
// ==/UserScript==
function createVideo(id, width, height, poster) {
return $.parseHTML('<video width="' + width + '" height="' + height + '" poster="' + poster + '" preload="auto" controls>' +
'<source src="http://video.golem.de/download/' + id + '?q=high"/>' +
'<source src="http://video.golem.de/download/' + id + '?q=medium"/>' +
'</video>');
}
function replaceVideos() {
$('div[id^="NVBPlayer"]').each(function(idx, el) {
el = $(el);
var id = el.attr('id').substring(9);
var embedded = el.find('embed');
var width = embedded.attr('width');
var height = embedded.attr('height');
var poster = embedded.attr('flashvars').replace(/^.*&image_src=([^&]+)&.*$/, '$1');
var video = createVideo(id, width, height, poster);
el.replaceWith(video);
});
$('object[id^="NVBPlayer"]').each(function(idx, el) {
el = $(el);
var id = el.attr('id').substring(9);
var width = el.attr('width');
var height = el.attr('height');
var flashvars = el.find('param[name="flashvars"]').attr('value');
var poster = flashvars.replace(/^.*&image_src=([^&]+)&.*$/, '$1');
var video = createVideo(id, width, height, poster);
el.replaceWith(video);
});
$('figure[id^="gvideo_"]').each(function(idx, el) {
el = $(el);
var id = el.attr('id').substring(7);
var playerEl = el.find('div[id="rmpPlayer' + id + '"]');
var width = playerEl.css('width').replace(/^([0-9]+).*/, '$1');
var height = playerEl.css('height').replace(/^([0-9]+).*/, '$1');
var posterEl = el.find('img[class="rmp-poster-img"]');
var poster = posterEl.attr('src');
var video = createVideo(id, width, height, poster);
el.replaceWith(video);
});
}
window.setTimeout(replaceVideos, 2000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment