From 21cab163d529fe1f54714c200d55f370c5b1a537 Mon Sep 17 00:00:00 2001 From: isqua Date: Thu, 29 Jan 2015 14:46:46 +0300 Subject: [PATCH 1/4] Refactor pleer.com embedding --- chrome_point_plus/js/point-plus.js | 81 ++++-------------------------- 1 file changed, 11 insertions(+), 70 deletions(-) diff --git a/chrome_point_plus/js/point-plus.js b/chrome_point_plus/js/point-plus.js index 8cb01c6..0c5e3dd 100644 --- a/chrome_point_plus/js/point-plus.js +++ b/chrome_point_plus/js/point-plus.js @@ -972,82 +972,23 @@ function set_posts_count_label() { } function parse_pleercom_links(current_options) { - if (current_options.is('option_embedding_pleercom_nokita_server')) { - parse_pleercom_links_nokita(); - } else { - parse_pleercom_links_ajax(current_options); - } -} -/** - * @deprecated since 1.19 - */ -function parse_pleercom_links_nokita() { - $('.post-content a').each(function(num, obj) { - var href = obj.href; - var n = null; + $('.post-content a').each(function(num, link) { + var $link = $(link); + var href = link.href; + var matches = href.match(new RegExp('^https?:\\/\\/pleer\\.com\\/tracks\\/([0-9a-z]+)', 'i')); - if (n = href.match(new RegExp('^https?:\\/\\/pleer\\.com\\/tracks\\/([0-9a-z]+)', 'i'))) { - var player = document.createElement('audio'); - $(player).attr({ - 'src': 'https://api.kanaria.ru/point/get_pleer_file.php?id=' + n[1], - 'controls': 'controls', - 'preload': 'none' - }); + if (matches) { + trackHref = 'http://embed.pleer.com/normal/track?id=' + matches[1] + '&t=grey'; - var player_div = document.createElement('div'); - $(player_div).addClass('embeded_audio').addClass('embeded_audio_' + n[1]); - player_div.appendChild(player); + $link.before('' + + '' + + ''); - obj.parentElement.insertBefore(player_div, obj); - } - }); -} - -function parse_pleercom_links_ajax(current_options) { - $('.post-content a').each(function(num, obj) { - var href = obj.href; - var n = null; - - 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], current_options); - } - }); -} - -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, - 'headers': [['Accept', '*'], ['Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8']], - 'success': function(a) { - var answer = JSON.parse(a); - var player = document.createElement('audio'); - // @todo Проверять существование track_link - $(player).attr({ - 'src': answer.track_link, - 'controls': 'controls', - 'preload': 'auto' - }); - $('.embeded_audio_' + this.settings.pleer_id)[0].appendChild(player); - - if (current_options.is('option_embedding_pleercom_orig_link', false)){ - $('.pleercom_original_link_'+this.settings.pleer_id).hide(); + if ( ! current_options.is('option_embedding_pleercom_orig_link')) { + $link.remove(); } - }, - 'error': function() { - console.log('Can not get pleer.com url'); - setTimeout(new Function('create_pleercom_ajax("' + this.settings.pleer_id + '");'), 1000); } - }); - } // Проставляем теги у постов From 08fa6c7bfafb31a78b8b58d2d3cf524060a6541a Mon Sep 17 00:00:00 2001 From: isqua Date: Thu, 29 Jan 2015 14:51:30 +0300 Subject: [PATCH 2/4] Remove pleercom_nokita_server option --- chrome_point_plus/_locales/en/messages.json | 3 - chrome_point_plus/_locales/ru/messages.json | 3 - chrome_point_plus/options.html | 639 ++++++++++---------- 3 files changed, 317 insertions(+), 328 deletions(-) diff --git a/chrome_point_plus/_locales/en/messages.json b/chrome_point_plus/_locales/en/messages.json index 2cd4fe4..21a482c 100644 --- a/chrome_point_plus/_locales/en/messages.json +++ b/chrome_point_plus/_locales/en/messages.json @@ -86,9 +86,6 @@ "option_embedding_pleercom": { "message": "Pleer.com ▼" }, - "option_embedding_pleercom_nokita_server": { - "message": "Use Nokita's server (deprecated)" - }, "option_embedding_coubcom": { "message": "Coub.com ▼" }, diff --git a/chrome_point_plus/_locales/ru/messages.json b/chrome_point_plus/_locales/ru/messages.json index 2be940c..d7fe463 100644 --- a/chrome_point_plus/_locales/ru/messages.json +++ b/chrome_point_plus/_locales/ru/messages.json @@ -86,9 +86,6 @@ "option_embedding_pleercom": { "message": "Pleer.com ▼" }, - "option_embedding_pleercom_nokita_server": { - "message": "Использовать сервер @NokitaKaze (deprecated)" - }, "option_embedding_coubcom": { "message": "Coub.com ▼" }, diff --git a/chrome_point_plus/options.html b/chrome_point_plus/options.html index b388067..14cd8fa 100644 --- a/chrome_point_plus/options.html +++ b/chrome_point_plus/options.html @@ -1,322 +1,317 @@ - - - - - - - - - -
- - -
-
-
- - - - - - - - - - - - -
- - - -
- - - - - -
- - - -
- - -
- - -
- -
- - - - -
- -
- - - - -
- -
- - - - - - -
- -
- - - - -
- - - -
- - - - -
-
- -
- - - - - -
- - - - -
- -
- - - - -
-
-
- -
-
- - - - -
- - - - - - - -
- - - -
- - - -
-
- - - - - - - - - - - -
- - - - -
- - - - -
- -
-
- - - -
- - - - - - -
- -
- - - - - - -
-
-
- -
-
-
-
-
- - - - - - - - - + + + + + + + + + +
+ + +
+
+
+ + + + + + + + + + + + +
+ + + +
+ + + + + +
+ + + +
+ + +
+ + +
+ +
+ + + + +
+ +
+ + + + +
+ +
+ + + + +
+ +
+ + + + +
+ + + +
+ + + + +
+
+ +
+ + + + + +
+ + + + +
+ +
+ + + + +
+
+
+ +
+
+ + + + +
+ + + + + + + +
+ + + +
+ + + +
+
+ + + + + + + + + + + +
+ + + + +
+ + + + +
+ +
+
+ + + +
+ + + + + + +
+ +
+ + + + + + +
+
+
+ +
+
+
+
+
+ + + + + + + + + From 0f9cb4e1672d6fe3b810f7e470258b4f48bef64b Mon Sep 17 00:00:00 2001 From: isqua Date: Sat, 31 Jan 2015 13:15:25 +0300 Subject: [PATCH 3/4] Refactor instagram embedding --- chrome_point_plus/js/point-plus.js | 53 ++++++++++++++---------------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/chrome_point_plus/js/point-plus.js b/chrome_point_plus/js/point-plus.js index 0c5e3dd..598a9db 100644 --- a/chrome_point_plus/js/point-plus.js +++ b/chrome_point_plus/js/point-plus.js @@ -1553,41 +1553,36 @@ function twitter_tweet_embedding_parse_links() { function instagram_posts_embedding_init(options) { var regex = new RegExp('^https?://(www\\.)?instagram\\.com/p/([\\w-]+)/?', 'i'); - $('.post-content a:not(.booru_pic)').each(function(num, $link) { - var href = $link.href; - var n; + $('.post-content a:not(.booru_pic)').each(function(num, link) { + var $link = $(link); + var href = link.href; + var matches = href.match(regex); - if (n = href.match(regex)) { - $ajax({ - 'url': 'https://api.instagram.com/oembed?url=' + urlencode('http://instagram.com/p/' + n[2] + '/'), - 'success': function(text) { - var answer = JSON.parse(text); - var new_post = document.createElement('a'); - $(new_post).attr({ - 'id': 'instagram-' + num, - 'href': answer.thumbnail_url, - 'title': answer.title, - 'target': '_blank', - 'data-fancybox-group': (options.is('option_fancybox_bind_images_to_one_flow')) - ? 'one_flow_gallery' : '', - 'data-fancybox-title': (options.is('option_fancybox_smart_hints')) - ? answer.title : ' ' - }).addClass('postimg instagram-post-embedded'); + if (matches) { + $.ajax('https://api.instagram.com/oembed?url=' + 'http://instagr.am/p/' + matches[2] + '/', { + dataType: 'json', + success: function(response) { + var $imgLink = $('' + response.title + ''); - var image = document.createElement('img'); - image.alt = new_post.title; - image.src = new_post.href; - new_post.appendChild(image); + $imgLink + .addClass('postimg instagram-post-embedded') + .attr({ + id: 'instagram-' + num, + href: 'http://instagram.com/p/' + matches[2] + '/media/?size=l', + title: response.title, + traget: '_blank', + 'data-fancybox-group': (options.is('option_fancybox_bind_images_to_one_flow')) ? 'one_flow_gallery' : '', + 'data-fancybox-title': (options.is('option_fancybox_smart_hints')) ? response.title : '' + }); - // Leave or replace - if (options.is('option_embedding_instagram_posts_orig_link')) { - $link.parentElement.insertBefore(new_post, $link); - } else { - $($link).replaceWith(new_post); + $link.before($imgLink); + + if ( ! options.is('option_embedding_instagram_posts_orig_link')) { + $link.remove(); } } }); - } }); } From 1f97b6d19c45e7cac773bc02016a6fa4fb43cb98 Mon Sep 17 00:00:00 2001 From: isqua Date: Thu, 29 Jan 2015 14:47:07 +0300 Subject: [PATCH 4/4] Remove bquery_ajax --- chrome_point_plus/js/bquery_ajax.js | 113 ---------------------------- chrome_point_plus/manifest.json | 16 ++-- 2 files changed, 7 insertions(+), 122 deletions(-) delete mode 100644 chrome_point_plus/js/bquery_ajax.js diff --git a/chrome_point_plus/js/bquery_ajax.js b/chrome_point_plus/js/bquery_ajax.js deleted file mode 100644 index 72a7603..0000000 --- a/chrome_point_plus/js/bquery_ajax.js +++ /dev/null @@ -1,113 +0,0 @@ -/** - * @deprecated since 1.36.0 - */ -function $ajax_prot(settings){ - if (settings==undefined){return;} - if (settings['url'] ==undefined){return;}this.url=settings['url']; - if (settings['async'] !==undefined){this.async =settings['async'];} - if (settings['type'] !==undefined){this.type =settings['type'];} - if (settings['postdata']!==undefined){this.postdata=settings['postdata'];} - if (settings['dont_set_content_type']!==undefined){ - this.dont_set_content_type=settings['dont_set_content_type']; - } - - this.xhr=new XMLHttpRequest(); - this.xhr.parent =this; - this.xhr.settings=settings; - this.xhr.success =settings['success']; - this.xhr.error =settings['error']; - this.xhr.onreadystatechange=this.change; - this.xhr.open(this.type, this.url, this.async); - if ((this.type=='POST')&& !this.dont_set_content_type){ - this.xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); - } - if (settings.headers!==undefined){ - for (var i=0;i0){ - s+='\\'+text[i]; - }else{ - s+=text[i]; - } - } - return s; -} - -/** - * @deprecated since 1.36.0 - */ -function sad_xml_getnode(node,path){//node as domNode - if ('' ==path){return node;} - if ('#'==path){return node.textContent || node.text;} - - var ri=new RegExp('^([a-z0-9.:_-]*)(\\|[0-9]+)?(/?(.*))?','i'); - var t=path.match(ri); - if (t[1].length<1){return undefined;} - if (t[2]==undefined){t[2]='';} - if (t[4]==undefined){t[4]='';} - - var k=parseInt(t[2].substr(1)); - if (!(k>0)){k=1;} - var r=new RegExp('^'+sad_safe_reg(t[1])+'$'); - for (var i=0;i