code to video on darkwarez.pl

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==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>');
		}
	});
});