From 4b13936dfa91ce9ddd5587e222842a7ddadb9d88 Mon Sep 17 00:00:00 2001 From: Nokita Kaze Date: Tue, 25 Nov 2014 16:43:21 +0300 Subject: [PATCH] =?UTF-8?q?+=20=D0=9F=D0=B0=D1=80=D1=81=D0=B5=D1=80=20coub?= =?UTF-8?q?.com?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chrome_point_plus/_locales/en/messages.json | 3 ++ chrome_point_plus/_locales/ru/messages.json | 3 ++ chrome_point_plus/js/point-plus.js | 41 ++++++++++++++++++++- chrome_point_plus/options.html | 8 ++++ 4 files changed, 53 insertions(+), 2 deletions(-) diff --git a/chrome_point_plus/_locales/en/messages.json b/chrome_point_plus/_locales/en/messages.json index 2b13006..2da5306 100644 --- a/chrome_point_plus/_locales/en/messages.json +++ b/chrome_point_plus/_locales/en/messages.json @@ -83,6 +83,9 @@ "option_embedding_pleercom_nokita_server": { "message": "Use Nokita's server instead of AJAX to get mp3 link" }, + "option_embedding_coubcom": { + "message": "Coub.com ▼" + }, "option_nsfw": { "message": "NSFW content filtering" }, diff --git a/chrome_point_plus/_locales/ru/messages.json b/chrome_point_plus/_locales/ru/messages.json index 8ea3d9b..e270a28 100644 --- a/chrome_point_plus/_locales/ru/messages.json +++ b/chrome_point_plus/_locales/ru/messages.json @@ -83,6 +83,9 @@ "option_embedding_pleercom_nokita_server": { "message": "Использовать сервер @NokitaKaze вместо AJAX-запроса для получения mp3" }, + "option_embedding_coubcom": { + "message": "Coub.com ▼" + }, "option_nsfw": { "message": "Фильтрация NSFW-контента" }, diff --git a/chrome_point_plus/js/point-plus.js b/chrome_point_plus/js/point-plus.js index 8cc841c..1b8f02f 100644 --- a/chrome_point_plus/js/point-plus.js +++ b/chrome_point_plus/js/point-plus.js @@ -28,8 +28,11 @@ $(document).ready(function() { var options = sync_data.options; // Options debug - console.debug('Options loaded: '+options); - + try { + console.debug('Options loaded: %O', current_options); + }catch(e){ + console.error("Я идиот, убейте меня кто-нибудь: %O", e); + } create_tag_system(); // Embedding @@ -92,6 +95,11 @@ $(document).ready(function() { if (options.option_embedding_pleercom.value == true) { parse_pleercom_links(); } + + // Parse coub.com links and create iframe instead + if (options.option_embedding_coubcom.value == true) { + parse_coub_links(); + } } // Fancybox @@ -1016,3 +1024,32 @@ function draft_save_check() { }, 1000); }); } + + +// Парсим ссылки на coub +function parse_coub_links() { + $('.post-content a').each(function(num, obj) { + var href = obj.href; + var n = null; + + if (n = href.match(new RegExp('^https?:\\/\\/coub\\.com\\/view\\/([0-9a-z]+)', 'i'))) { + var player = document.createElement('iframe'); + var parent_width = $(obj.parentElement).width(); + $(player).attr({ + 'src': 'https://coub.com/embed/' + n[1] + '?muted=false&autostart=false&originalSize=false&hideTopBar=false&startWithHD=true', + 'allowfullscreen': 'true' + }).css({ + 'max-width': '640px', + 'border': 'none', + 'width': Math.floor(parent_width * 0.9), + 'height': Math.ceil(parent_width * 0.9 * 480 / 640) + }).addClass('embeded_video').addClass('embeded_video_' + n[1]); + + obj.parentElement.insertBefore(player, obj); + + if (current_options.option_embedding_coubcom_orig_link.value == false) { + $(obj).hide(); + } + } + }); +} diff --git a/chrome_point_plus/options.html b/chrome_point_plus/options.html index d7e045c..aa4f4c9 100644 --- a/chrome_point_plus/options.html +++ b/chrome_point_plus/options.html @@ -89,6 +89,14 @@ + +
+ + +
+ +
+