code to video on darkwarez.pl

Zamiana linków do plików webm/mp4/ogg oraz streamable.com umieszczonych w tagu [code] na player

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name			code to video on darkwarez.pl
// @version			1.1
// @author			norbi1952
// @description		Zamiana linków do plików webm/mp4/ogg oraz streamable.com umieszczonych w tagu [code] na player
// @include			http://darkwarez.pl/*
// @include			https://darkwarez.pl/*
// @require			https://cdn.jsdelivr.net/jquery/3.1.1/jquery.min.js
// @namespace https://greasyfork.org/users/9446
// ==/UserScript==
$(document).ready(function() {
	$('td.code').each(function() {
		var str = $(this).text();
		var codeTag = $(this).closest('table');

		var streamableRegex = /(?:http|https):\/\/streamable\.com\/(?:[a-z][a-z0-9_]*)/gi;
		var isStreamable = streamableRegex.test(str);

		var regex = /(?:http|https):\/\/.+(?:webm|mp4|ogg)\b/gi;
		var newStr = str;

		var replaced = str.search(regex) >= 0;

		if(replaced) {
			newStr = newStr.replace(regex, '<br><video controls muted preload="metadata" style="max-width: 100%;"><source src="$&">Your browser does not support the video tag.</video><br><br>');
		}

		if(isStreamable) {
			newStr = newStr.replace(streamableRegex, '<div style="width: 100%; height: 0px; position: relative; padding-bottom: 56.200%;"><iframe src="$&" frameborder="0" allowfullscreen webkitallowfullscreen mozallowfullscreen scrolling="no" style="width: 100%; height: 100%; position: absolute;"></iframe><script async defer src="https://v.embedcdn.com/embed.js"></script></div><br>').replace(RegExp('streamable.com/', 'g'), 'streamable.com/e/');
		}

		if(isStreamable || replaced) {
			codeTag.replaceWith('<div id="player" style="font-size: 12px; line-height: 18px;">' + newStr + '</div>');
		}
	});
});