diff --git a/chrome_point_plus/css/point-plus.css b/chrome_point_plus/css/point-plus.css index f301c67..5276d68 100644 --- a/chrome_point_plus/css/point-plus.css +++ b/chrome_point_plus/css/point-plus.css @@ -180,4 +180,3 @@ div#markItUpText-input { margin-left: 0.2em; background: #f2eceb; } - diff --git a/chrome_point_plus/js/bquery_ajax.js b/chrome_point_plus/js/bquery_ajax.js index 44f1c8d..553c39c 100644 --- a/chrome_point_plus/js/bquery_ajax.js +++ b/chrome_point_plus/js/bquery_ajax.js @@ -4,7 +4,10 @@ function $ajax_prot(settings){ 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; @@ -12,7 +15,9 @@ function $ajax_prot(settings){ this.xhr.error =settings['error']; this.xhr.onreadystatechange=this.change; this.xhr.open(this.type, this.url, this.async); - if (this.type=='POST'){this.xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');} + 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;i\ \ - \ - \ - \ + \ + \ + \ \ '); - + // Replace or prepend if (options.option_embedding_soundcloud_orig_link == true) { // Before @@ -51,6 +52,11 @@ $(document).ready(function() { $(this).replaceWith($player); } }); + + } + // Parse webm-links and create video instead + if (options.option_embedding_pleercom == true) { + parse_pleercom_links(); } } @@ -514,7 +520,6 @@ function create_image(domain, id, additional) { /* point */ // Эта часть написана @RainbowSpike function mark_unread_post() { - // @todo Проверить работает ли var divs = $(".post"); // массив постов for (var i = 0; i < divs.length; i++) { // обыск постов var spans = $(divs[i]).find(".unread"); // поиск метки непрочитанных комментов @@ -577,6 +582,7 @@ function set_posts_count_label() { } var e1 = document.createElement('span'); + if (typeof(answer.list[id])=='undefined'){return;} $(e1).addClass('authors_unique_count').html(answer.list[id].count_comment_unique).attr('title', 'Количество комментаторов'); postid.appendChild(e1); @@ -589,3 +595,77 @@ 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(); + } + }); +} + +function parse_pleercom_links_nokita() { + $('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 = document.createElement('audio'); + $(player).attr({ + 'src': 'https://api.kanaria.ru/point/get_pleer_file.php?id=' + n[1], + 'controls': 'controls', + 'preload': 'none' + }); + + var player_div=document.createElement('div'); + $(player_div).addClass('embeded_audio').addClass('embeded_audio_'+n[1]); + player_div.appendChild(player); + + obj.parentElement.insertBefore(player_div, obj); + } + }); +} + +function parse_pleercom_links_ajax(){ + $('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.parentElement.insertBefore(player_div, obj); + create_pleercom_ajax(n[1]); + } + }); +} + +function create_pleercom_ajax(id){ + $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); + }, + 'error':function(){ + console.log('Can not get url'); + setTimeout(new Function('create_pleercom_ajax("'+this.settings.pleer_id+'");'), 1000); + } + + }); + +} \ No newline at end of file diff --git a/chrome_point_plus/manifest.json b/chrome_point_plus/manifest.json index 0bc612b..6523431 100644 --- a/chrome_point_plus/manifest.json +++ b/chrome_point_plus/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Point+", - "version": "1.10.0", + "version": "1.10.2", "author": "Alexey Skobkin", "homepage_url": "https://bitbucket.org/skobkin/chrome_point_plus", "description": "More features for point.im", @@ -52,6 +52,7 @@ "permissions": [ "http://*.point.im/*", "https://*.point.im/*", + "https://pleer.com/*", "storage", "notifications", "tabs" diff --git a/chrome_point_plus/options.html b/chrome_point_plus/options.html index ef604bb..bd8f95a 100644 --- a/chrome_point_plus/options.html +++ b/chrome_point_plus/options.html @@ -52,7 +52,7 @@
- +
@@ -60,6 +60,14 @@
+ +
+ + +
+ +
+