code to video on darkwarez.pl

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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>');
		}
	});
});