From 3aad05956ef4c9bbd142bd278e49591877de14b7 Mon Sep 17 00:00:00 2001 From: Nokita Kaze Date: Tue, 25 Nov 2014 13:50:09 +0300 Subject: [PATCH 1/6] =?UTF-8?q?*=20=D0=9F=D0=B0=D1=80=D0=BE=D1=87=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8=D0=B9?= =?UTF-8?q?=20=D1=81=20=D0=BE=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA?= =?UTF-8?q?=D0=BE=D0=B9=20=D0=B2=D0=B8=D0=B4=D0=B5=D0=BE-=D0=B3=D0=B0?= =?UTF-8?q?=D0=BB=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chrome_point_plus/options.html | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/chrome_point_plus/options.html b/chrome_point_plus/options.html index 629fe36..8ca7cf1 100644 --- a/chrome_point_plus/options.html +++ b/chrome_point_plus/options.html @@ -50,11 +50,20 @@
+ + + +
+ + +
+
From d14e69c7b57305fccde44f964c3ca8fc3e90aa01 Mon Sep 17 00:00:00 2001 From: Nokita Kaze Date: Wed, 26 Nov 2014 23:48:08 +0300 Subject: [PATCH 2/6] =?UTF-8?q?*=20*=20=D0=92=D1=8B=D0=B1=D0=BE=D1=80=20?= =?UTF-8?q?=D0=BF=D0=B0=D1=80=D1=81=D0=B8=D0=BD=D0=B3=D0=B0=20=D1=81=D1=81?= =?UTF-8?q?=D1=8B=D0=BB=D0=BE=D0=BA=20=D0=BD=D0=B0=20=D0=B2=D0=B8=D0=B4?= =?UTF-8?q?=D0=B5=D0=BE=20=D1=87=D0=B5=D1=80=D0=B5=D0=B7=20=D1=80=D0=B0?= =?UTF-8?q?=D0=B4=D0=B8=D0=BE-=D0=B1=D0=B0=D1=82=D0=BE=D0=BD=20-=20=D0=9E?= =?UTF-8?q?=D0=BF-=D0=BF=D0=B0,=20=D1=81=D0=B8=D1=88=D0=BA=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D0=B0=D0=B9=D0=BB.=20=D0=9C=D0=B5=D0=BD=D1=8F=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=B4=D0=B7=D0=B0=D0=B5=D0=B1=D0=B0=D0=BB=D0=BE,=20?= =?UTF-8?q?=D1=87=D1=82=D0=BE=20=D0=BD=D0=B0=20=D1=81=D1=82=D1=80=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D1=86=D0=B5=20chrome://extensions/=20=D0=BA=D0=B0?= =?UTF-8?q?=D0=BA=D0=BE=D0=B5-=D1=82=D0=BE=20=D0=B3=D0=BE=D0=B2=D0=BD?= =?UTF-8?q?=D0=BE=20=D0=B2=20=D0=BE=D0=BF=D1=86=D0=B8=D1=8F=D1=85=20+=20?= =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=BC=D0=B5=D0=BD=D0=BD=D0=B0=D1=8F=20?= =?UTF-8?q?current=5Foptions,=20=D0=B2=20=D0=BA=D0=BE=D1=82=D0=BE=D1=80?= =?UTF-8?q?=D0=BE=D0=B9=20=D1=81=D0=BE=D0=B4=D0=B5=D1=80=D0=B6=D0=B8=D1=82?= =?UTF-8?q?=D1=81=D1=8F=20=D1=82=D0=B5=D0=BA=D1=83=D1=89=D0=B5=D0=B5=20(?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BC=D0=BE=D0=BC=D0=B5=D0=BD=D1=82=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D0=B8)=20=D1=81=D0=BE?= =?UTF-8?q?=D0=B4=D0=B5=D1=80=D0=B6=D0=B8=D0=BC=D0=BE=D0=B5=20=D0=BE=D0=BF?= =?UTF-8?q?=D1=86=D0=B8=D0=B9.=20=D0=9D=D0=B5=D1=87=D0=B5=D0=B3=D0=BE=20?= =?UTF-8?q?=D0=B4=D1=83=D0=BF=D0=BB=D0=B8=D1=82=D1=8C=D1=81=D1=8F=20=D0=B2?= =?UTF-8?q?=20=D0=B0=D1=81=D0=B8=D0=BD=D1=85=D1=80=D0=BE=D0=BD=D0=BD=D0=BE?= =?UTF-8?q?=D0=B5=20=D0=BE=D0=B1=D1=80=D0=B0=D1=89=D0=B5=D0=BD=D0=B8=D0=B5?= =?UTF-8?q?=20=D0=BA=20=D0=BE=D0=BF=D1=86=D0=B8=D1=8F=D0=BC=20*=20=D0=9F?= =?UTF-8?q?=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8=D0=BB=20=D1=81=D0=B5=D0=BB?= =?UTF-8?q?=D0=B5=D0=BA=D1=82=D0=BE=D1=80=D1=8B.=20=D0=AF=20=D1=82=D0=B0?= =?UTF-8?q?=D0=BA=D0=BE=D0=B9=20=D0=BD=D0=B0=D1=80=D0=BA=D0=BE=D0=BC=D0=B0?= =?UTF-8?q?=D0=BD=20=D0=B1=D1=8B=D0=BB=20=D1=87=D1=82=D0=BE=20=D0=BB=D0=B8?= =?UTF-8?q?=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chrome_point_plus/_locales/en/messages.json | 14 +++++-- chrome_point_plus/_locales/ru/messages.json | 14 +++++-- chrome_point_plus/js/point-plus.js | 45 ++++++++++++--------- chrome_point_plus/options.html | 14 +++---- 4 files changed, 52 insertions(+), 35 deletions(-) diff --git a/chrome_point_plus/_locales/en/messages.json b/chrome_point_plus/_locales/en/messages.json index c3ddffa..6c19b2c 100644 --- a/chrome_point_plus/_locales/en/messages.json +++ b/chrome_point_plus/_locales/en/messages.json @@ -56,11 +56,17 @@ "option_images_load_booru": { "message": "Load pictures from Booru, Tumblr and some other sites" }, - "option_videos_parse_webm": { - "message": "Parse webm-links and create video instead" + "option_videos_parse_links": { + "message": "Parse video links and create video instead" }, - "option_videos_parse_all_videos": { - "message": "Parse all links to videos and create video instead" + "option_videos_parse_webm": { + "message": "Only webm" + }, + "option_videos_parse_all_links": { + "message": "Parse all links" + }, + "option_videos_parse_leave_links": { + "message": "Don't delete link itself" }, "option_embedding_soundcloud": { "message": "Soundcloud ▼" diff --git a/chrome_point_plus/_locales/ru/messages.json b/chrome_point_plus/_locales/ru/messages.json index 117b315..18b16f8 100644 --- a/chrome_point_plus/_locales/ru/messages.json +++ b/chrome_point_plus/_locales/ru/messages.json @@ -56,11 +56,17 @@ "option_images_load_booru": { "message": "Загружать картинки с Booru, Tumblr и других сайтов" }, - "option_videos_parse_webm": { - "message": "Оборачивать ссылки на webm в тег <video>" + "option_videos_parse_links": { + "message": "Превращать ссылки на видео в видео" }, - "option_videos_parse_all_videos": { - "message": "Оборачивать ссылки на всё видео в тег <video>" + "option_videos_parse_webm": { + "message": "Только webm" + }, + "option_videos_parse_all_links": { + "message": "Все ссылки на видео" + }, + "option_videos_parse_leave_links": { + "message": "Оставлять ссылку на видео" }, "option_embedding_soundcloud": { "message": "Soundcloud ▼" diff --git a/chrome_point_plus/js/point-plus.js b/chrome_point_plus/js/point-plus.js index 6f20cde..40992bb 100644 --- a/chrome_point_plus/js/point-plus.js +++ b/chrome_point_plus/js/point-plus.js @@ -26,9 +26,9 @@ $(document).ready(function() { // Loading options chrome.storage.sync.get('options', function(sync_data) { var options = sync_data.options; - + // Options debug - console.debug('Options loaded: %O', options); + console.debug('Options loaded: '+options); create_tag_system(); @@ -39,8 +39,8 @@ $(document).ready(function() { load_all_booru_images(); } // Parse webm-links and create video instead - if (options.option_videos_parse_webm.value == true) { - if (options.option_videos_parse_all_videos.value == true) { + if (options.option_videos_parse_links.value == true) { + if (options.option_videos_parse_links_type.value == "all") { parse_all_videos(); } else { parse_webm(); @@ -81,7 +81,8 @@ $(document).ready(function() { }); } - // Parse webm-links and create video instead + + // Parse pleer.com links and create audio instead if (options.option_embedding_pleercom.value == true) { parse_pleercom_links(); } @@ -545,11 +546,13 @@ var months = [ 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ]; +// Копия опций +var current_options; // Картинки с бурятников var booru_picture_count = 0; function load_all_booru_images() { - $('a').each(function(num, obj) { + $('.post-content a').each(function(num, obj) { if ($(obj).hasClass('booru_pic')) { return; } @@ -652,7 +655,7 @@ function mark_unread_post() { // Webm function parse_webm() { - $('a').each(function(num, obj) { + $('.post-content a').each(function(num, obj) { if ($(obj).hasClass('booru_pic')) { return; } @@ -669,12 +672,16 @@ function parse_webm() { }).addClass('parsed-webm-link'); obj.parentElement.insertBefore(player, obj); + + if (current_options.option_videos_parse_leave_links.value == false) { + $(obj).hide(); + } } }); } function parse_all_videos() { - $('a').each(function(num, obj) { + $('.post-content a').each(function(num, obj) { if ($(obj).hasClass('booru_pic')) { return; } @@ -691,6 +698,10 @@ function parse_all_videos() { }).addClass('parsed-webm-link'); obj.parentElement.insertBefore(player, obj); + + if (current_options.option_videos_parse_leave_links.value == false) { + $(obj).hide(); + } } }); } @@ -751,17 +762,15 @@ function set_posts_count_label() { } function parse_pleercom_links() { - chrome.storage.sync.get(ppOptions, function(options) { - if (options.option_embedding_pleercom_nokita_server) { - parse_pleercom_links_nokita(); - } else { - parse_pleercom_links_ajax(); - } - }); + if (current_options.option_embedding_pleercom_nokita_server.value) { + parse_pleercom_links_nokita(); + } else { + parse_pleercom_links_ajax(); + } } function parse_pleercom_links_nokita() { - $('a').each(function(num, obj) { + $('.post-content a').each(function(num, obj) { var href = obj.href; var n = null; @@ -783,7 +792,7 @@ function parse_pleercom_links_nokita() { } function parse_pleercom_links_ajax() { - $('a').each(function(num, obj) { + $('.post-content a').each(function(num, obj) { var href = obj.href; var n = null; @@ -816,7 +825,7 @@ function create_pleercom_ajax(id) { $('.embeded_audio_' + this.settings.pleer_id)[0].appendChild(player); }, 'error': function() { - console.log('Can not get url'); + console.log('Can not get pleer.com url'); setTimeout(new Function('create_pleercom_ajax("' + this.settings.pleer_id + '");'), 1000); } diff --git a/chrome_point_plus/options.html b/chrome_point_plus/options.html index 8ca7cf1..e21907d 100644 --- a/chrome_point_plus/options.html +++ b/chrome_point_plus/options.html @@ -50,20 +50,16 @@
-
- - + +
+
+ +
From 572f137b5d78a284013d8da4e33dc09d16eda7a5 Mon Sep 17 00:00:00 2001 From: Nokita Kaze Date: Tue, 25 Nov 2014 16:02:39 +0300 Subject: [PATCH 3/6] =?UTF-8?q?*=20=D0=9F=D0=B0=D1=80=D1=81=D0=B5=D1=80=20?= =?UTF-8?q?=D0=B0=D1=83=D0=B4=D0=B8=D0=BE-=D1=81=D1=81=D1=8B=D0=BB=D0=BE?= =?UTF-8?q?=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chrome_point_plus/_locales/en/messages.json | 7 ++- chrome_point_plus/_locales/ru/messages.json | 5 +- chrome_point_plus/js/point-plus.js | 58 ++++++++++++++++++++- chrome_point_plus/options.html | 12 +++++ 4 files changed, 78 insertions(+), 4 deletions(-) diff --git a/chrome_point_plus/_locales/en/messages.json b/chrome_point_plus/_locales/en/messages.json index 6c19b2c..2b13006 100644 --- a/chrome_point_plus/_locales/en/messages.json +++ b/chrome_point_plus/_locales/en/messages.json @@ -56,6 +56,9 @@ "option_images_load_booru": { "message": "Load pictures from Booru, Tumblr and some other sites" }, + "option_audios_parse_links": { + "message": "Parse audio links and create audio instead" + }, "option_videos_parse_links": { "message": "Parse video links and create video instead" }, @@ -66,7 +69,7 @@ "message": "Parse all links" }, "option_videos_parse_leave_links": { - "message": "Don't delete link itself" + "message": "Leave original link" }, "option_embedding_soundcloud": { "message": "Soundcloud ▼" @@ -138,7 +141,7 @@ "message": "@ before username" }, "option_other_hightlight_post_comments": { - "message": "Hightlight post with new comments (using @NokitaKaze server)" + "message": "Highlight post with new comments" }, "option_other_show_recommendation_count": { "message": "Show recommendation count and unique commentators count (using @NokitaKaze server)" diff --git a/chrome_point_plus/_locales/ru/messages.json b/chrome_point_plus/_locales/ru/messages.json index 18b16f8..8ea3d9b 100644 --- a/chrome_point_plus/_locales/ru/messages.json +++ b/chrome_point_plus/_locales/ru/messages.json @@ -56,6 +56,9 @@ "option_images_load_booru": { "message": "Загружать картинки с Booru, Tumblr и других сайтов" }, + "option_audios_parse_links": { + "message": "Превращать ссылки на аудио в аудио" + }, "option_videos_parse_links": { "message": "Превращать ссылки на видео в видео" }, @@ -138,7 +141,7 @@ "message": "Пёс перед юзернеймом" }, "option_other_hightlight_post_comments": { - "message": "Подсвечивать посты с новыми комментариями (используя сервер @NokitaKaze)" + "message": "Подсвечивать посты с новыми комментариями" }, "option_other_show_recommendation_count": { "message": "Показывать количество рекомендаций и уникальных комментаторов в посте (используя сервер @NokitaKaze)" diff --git a/chrome_point_plus/js/point-plus.js b/chrome_point_plus/js/point-plus.js index 40992bb..3e2c7cf 100644 --- a/chrome_point_plus/js/point-plus.js +++ b/chrome_point_plus/js/point-plus.js @@ -38,6 +38,7 @@ $(document).ready(function() { if (options.option_images_load_booru.value == true) { load_all_booru_images(); } + // Parse webm-links and create video instead if (options.option_videos_parse_links.value == true) { if (options.option_videos_parse_links_type.value == "all") { @@ -47,6 +48,11 @@ $(document).ready(function() { } } + // Parse audio links + if (options.option_audios_parse_links.value == true) { + parse_all_audios(); + } + // Soundcloud if (options.option_embedding_soundcloud.value == true) { // Injecting JS API @@ -680,6 +686,7 @@ function parse_webm() { }); } +// Видео function parse_all_videos() { $('.post-content a').each(function(num, obj) { if ($(obj).hasClass('booru_pic')) { @@ -692,7 +699,7 @@ function parse_all_videos() { if (n = href.match(new RegExp('\\.(webm|avi|mp4|mpg|mpeg)(\\?.+)?$', 'i'))) { var player = document.createElement('video'); var mime = video_extension_to_mime(n[1]); - $(player).html('').attr('controls', 'controls').css({ + $(player).html('').attr('controls', 'controls').css({ 'display': 'block', 'max-width': '95%' }).addClass('parsed-webm-link'); @@ -717,6 +724,50 @@ function video_extension_to_mime(extension) { } +// Аудио +function parse_all_audios(){ + $('.post-content a').each(function(num, obj) { + if ($(obj).hasClass('booru_pic')) { + return; + } + + var href = obj.href; + var n = null; + + if (n = href.match(new RegExp('^https?:\\/\\/([a-z0-9.-]+)/[a-z0-9/.%-]+\\.(mp3|ogg|wav)(\\?.+)?$', 'i'))) { + var domain = n[1]; + // Проверяем откуда мы грузимся + if (domain.match(new RegExp('\\.vk\\.me$', 'i'))){ + // Так то ж Контакт! + if (!n[3].match('extra\\=', 'i')){ + return; + } + } + + var player = document.createElement('audio'); + var mime = audio_extension_to_mime(n[2]); + $(player).html('').attr('controls', 'controls').css({ + 'display': 'block', + 'max-width': '350px' + }).addClass('parsed-audio-link'); + + obj.parentElement.insertBefore(player, obj); + + if (current_options.option_audios_parse_leave_links.value == false) { + $(obj).hide(); + } + } + }); +} + +function audio_extension_to_mime(extension) { + switch (extension) { + case 'mp3': return 'audio/mpeg'; + case 'ogg': return 'audio/ogg; codecs=vorbis'; + case 'wav': return 'audio/vnd.wave'; + } +} + // Плашки у постов function set_posts_count_label() { var ids = []; @@ -799,6 +850,7 @@ function parse_pleercom_links_ajax() { if (n = href.match(new RegExp('^https?:\\/\\/pleer\\.com\\/tracks\\/([0-9a-z]+)', 'i'))) { var player_div = document.createElement('div'); $(player_div).addClass('embeded_audio').addClass('embeded_audio_' + n[1]); + $(obj).addClass('pleercom_original_link_'+n[1]); obj.parentElement.insertBefore(player_div, obj); create_pleercom_ajax(n[1]); } @@ -823,6 +875,10 @@ function create_pleercom_ajax(id) { 'preload': 'auto' }); $('.embeded_audio_' + this.settings.pleer_id)[0].appendChild(player); + + if (current_options.option_embedding_pleercom_orig_link.value == false){ + $('.pleercom_original_link_'+this.settings.pleer_id).hide(); + } }, 'error': function() { console.log('Can not get pleer.com url'); diff --git a/chrome_point_plus/options.html b/chrome_point_plus/options.html index e21907d..d7e045c 100644 --- a/chrome_point_plus/options.html +++ b/chrome_point_plus/options.html @@ -62,6 +62,14 @@
+
+ + +
+ +
+
+
@@ -76,6 +84,10 @@
+ +
+ +
From 817ef68473ff291b338db60b805cf65a287bd1fb Mon Sep 17 00:00:00 2001 From: Nokita Kaze Date: Tue, 25 Nov 2014 16:10:38 +0300 Subject: [PATCH 4/6] =?UTF-8?q?*=20=D0=A2=D0=B0=D0=BA,=20=D0=B2=D0=BE?= =?UTF-8?q?=D1=82=20=D1=82=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20=D1=80=D0=B0?= =?UTF-8?q?=D0=B1=D0=BE=D1=82=D0=B0=D0=B5=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chrome_point_plus/js/point-plus.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/chrome_point_plus/js/point-plus.js b/chrome_point_plus/js/point-plus.js index 3e2c7cf..8cc841c 100644 --- a/chrome_point_plus/js/point-plus.js +++ b/chrome_point_plus/js/point-plus.js @@ -721,7 +721,6 @@ function video_extension_to_mime(extension) { case 'mpg' :return 'video/mp4;'; case 'mpeg':return 'video/mp4;'; } - } // Аудио @@ -734,11 +733,14 @@ function parse_all_audios(){ var href = obj.href; var n = null; - if (n = href.match(new RegExp('^https?:\\/\\/([a-z0-9.-]+)/[a-z0-9/.%-]+\\.(mp3|ogg|wav)(\\?.+)?$', 'i'))) { + if (n = href.match(new RegExp('^https?:\\/\\/([a-z0-9.-]+)\\/[a-z0-9_\\/.%-]+\\.(mp3|ogg|wav)(\\?.+)?$', 'i'))) { var domain = n[1]; // Проверяем откуда мы грузимся if (domain.match(new RegExp('\\.vk\\.me$', 'i'))){ // Так то ж Контакт! + if (typeof(n[3])=='undefined'){ + return; + } if (!n[3].match('extra\\=', 'i')){ return; } From 4b13936dfa91ce9ddd5587e222842a7ddadb9d88 Mon Sep 17 00:00:00 2001 From: Nokita Kaze Date: Tue, 25 Nov 2014 16:43:21 +0300 Subject: [PATCH 5/6] =?UTF-8?q?+=20=D0=9F=D0=B0=D1=80=D1=81=D0=B5=D1=80=20?= =?UTF-8?q?coub.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 @@ + +
+ + +
+ +
+
From 2a8ac706c9827133de5cb16af68db12152c1c842 Mon Sep 17 00:00:00 2001 From: Nokita Kaze Date: Wed, 26 Nov 2014 23:52:47 +0300 Subject: [PATCH 6/6] =?UTF-8?q?=D0=9D=D0=B0=20=D0=B1=D0=B8=D1=82=D0=B1?= =?UTF-8?q?=D0=B0=D0=BA=D0=B5=D1=82=D0=B5=20=D0=BE=D0=B1=D1=8A=D1=8F=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=D0=B8=20=D0=BD=D0=B5=D0=B4=D0=B5=D0=BB=D1=8E=20?= =?UTF-8?q?=D0=A2=D0=BE=D0=B9=D0=BE=D1=82=D1=8B:=20=D0=BA=D0=BE=D0=BB?= =?UTF-8?q?=D0=B8=D1=87=D0=B5=D1=81=D1=82=D0=B2=D0=BE=20=D0=BF=D0=B5=D1=80?= =?UTF-8?q?=D0=B5=D0=BC=D0=B5=D0=BD=D0=BD=D1=8B=D1=85=20=D0=B2=20=D0=B3?= =?UTF-8?q?=D0=BB=D0=BE=D0=B1=D0=B0=D0=BB=20=D1=81=D0=BA=D0=BE=D1=83=D0=BF?= =?UTF-8?q?=D0=B5=20=D1=81=D0=BE=D0=BA=D1=80=D0=B0=D1=82=D0=B8=D0=BB=D0=BE?= =?UTF-8?q?=D1=81=D1=8C=20=D0=BD=D0=B0=20=D0=BE=D0=B4=D0=BD=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chrome_point_plus/js/point-plus.js | 58 ++++++++++++++---------------- 1 file changed, 27 insertions(+), 31 deletions(-) diff --git a/chrome_point_plus/js/point-plus.js b/chrome_point_plus/js/point-plus.js index 1b8f02f..00897cf 100644 --- a/chrome_point_plus/js/point-plus.js +++ b/chrome_point_plus/js/point-plus.js @@ -29,10 +29,8 @@ $(document).ready(function() { // Options debug try { - console.debug('Options loaded: %O', current_options); - }catch(e){ - console.error("Я идиот, убейте меня кто-нибудь: %O", e); - } + console.debug('Options loaded: %O', options); + }catch(e){} create_tag_system(); // Embedding @@ -45,15 +43,15 @@ $(document).ready(function() { // Parse webm-links and create video instead if (options.option_videos_parse_links.value == true) { if (options.option_videos_parse_links_type.value == "all") { - parse_all_videos(); + parse_all_videos(options); } else { - parse_webm(); + parse_webm(options); } } // Parse audio links if (options.option_audios_parse_links.value == true) { - parse_all_audios(); + parse_all_audios(options); } // Soundcloud @@ -93,12 +91,12 @@ $(document).ready(function() { // Parse pleer.com links and create audio instead if (options.option_embedding_pleercom.value == true) { - parse_pleercom_links(); + parse_pleercom_links(options); } // Parse coub.com links and create iframe instead if (options.option_embedding_coubcom.value == true) { - parse_coub_links(); + parse_coub_links(options); } } @@ -200,15 +198,15 @@ $(document).ready(function() { console.log('Hide NSFW posts in feed'); $('.post').addClass('hide-nsfw-posts'); } - } else { - // Blurred posts - if (options.option_nsfw_blur_posts_entire.value == true) { - console.log('Bluring NSFW posts'); - $('.post').addClass('blur-nsfw-entire'); - } else if (options.option_nsfw_blur_posts_images.value == true) { - console.log('Bluring images in NSFW posts'); - $('.post').addClass('blur-nsfw-images'); - } + } + + // Blurred posts + if (options.option_nsfw_blur_posts_entire.value == true) { + console.log('Bluring NSFW posts'); + $('.post').addClass('blur-nsfw-entire'); + } else if (options.option_nsfw_blur_posts_images.value == true) { + console.log('Bluring images in NSFW posts'); + $('.post').addClass('blur-nsfw-images'); } // Blurred comments @@ -560,9 +558,6 @@ var months = [ 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ]; -// Копия опций -var current_options; - // Картинки с бурятников var booru_picture_count = 0; function load_all_booru_images() { @@ -668,7 +663,7 @@ function mark_unread_post() { } // Webm -function parse_webm() { +function parse_webm(current_options) { $('.post-content a').each(function(num, obj) { if ($(obj).hasClass('booru_pic')) { return; @@ -695,7 +690,7 @@ function parse_webm() { } // Видео -function parse_all_videos() { +function parse_all_videos(current_options) { $('.post-content a').each(function(num, obj) { if ($(obj).hasClass('booru_pic')) { return; @@ -732,7 +727,7 @@ function video_extension_to_mime(extension) { } // Аудио -function parse_all_audios(){ +function parse_all_audios(current_options){ $('.post-content a').each(function(num, obj) { if ($(obj).hasClass('booru_pic')) { return; @@ -822,11 +817,11 @@ function set_posts_count_label() { } -function parse_pleercom_links() { +function parse_pleercom_links(current_options) { if (current_options.option_embedding_pleercom_nokita_server.value) { parse_pleercom_links_nokita(); } else { - parse_pleercom_links_ajax(); + parse_pleercom_links_ajax(current_options); } } @@ -852,7 +847,7 @@ function parse_pleercom_links_nokita() { }); } -function parse_pleercom_links_ajax() { +function parse_pleercom_links_ajax(current_options) { $('.post-content a').each(function(num, obj) { var href = obj.href; var n = null; @@ -862,18 +857,19 @@ function parse_pleercom_links_ajax() { $(player_div).addClass('embeded_audio').addClass('embeded_audio_' + n[1]); $(obj).addClass('pleercom_original_link_'+n[1]); obj.parentElement.insertBefore(player_div, obj); - create_pleercom_ajax(n[1]); + create_pleercom_ajax(n[1], current_options); } }); } -function create_pleercom_ajax(id) { +function create_pleercom_ajax(id, current_options) { $ajax({ 'url': 'https://pleer.com/site_api/files/get_url', 'type': 'post', 'postdata': 'action=download&id=' + id, 'dont_set_content_type': true, 'pleer_id': id, + 'current_options':current_options, 'headers': [['Accept', '*'], ['Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8']], 'success': function(a) { var answer = JSON.parse(a); @@ -886,7 +882,7 @@ function create_pleercom_ajax(id) { }); $('.embeded_audio_' + this.settings.pleer_id)[0].appendChild(player); - if (current_options.option_embedding_pleercom_orig_link.value == false){ + if (this.settings.current_options.option_embedding_pleercom_orig_link.value == false){ $('.pleercom_original_link_'+this.settings.pleer_id).hide(); } }, @@ -1027,7 +1023,7 @@ function draft_save_check() { // Парсим ссылки на coub -function parse_coub_links() { +function parse_coub_links(current_options) { $('.post-content a').each(function(num, obj) { var href = obj.href; var n = null;