К сожалению это невозможно. Браузер не даёт сделать Cross-site запрос.

No 'Access-Control-Allow-Origin' header is present on the requested resource
This commit is contained in:
Nokita Kaze 2014-11-16 15:10:11 +03:00
parent 78defcc344
commit efd276deec
5 changed files with 69 additions and 17 deletions

View file

@ -180,8 +180,3 @@ div#markItUpText-input {
margin-left: 0.2em; margin-left: 0.2em;
background: #f2eceb; background: #f2eceb;
} }
/* Embeded audio */
audio.embeded_audio{
display: block;
}

View file

@ -24,6 +24,7 @@ var ppOptions = [
'option_embedding_soundcloud_orig_link', 'option_embedding_soundcloud_orig_link',
// Pleer.com // Pleer.com
'option_embedding_pleercom', 'option_embedding_pleercom',
'option_embedding_pleercom_nokita_server',
// Fluid layout // Fluid layout
'option_fluid_layout', 'option_fluid_layout',
// Visual editor for posts // Visual editor for posts
@ -62,7 +63,8 @@ function pp_save_options() {
ppOptions.option_videos_parse_webm = $('#option-videos-parse-webm').prop('checked'); ppOptions.option_videos_parse_webm = $('#option-videos-parse-webm').prop('checked');
ppOptions.option_embedding_soundcloud = $('#option-embedding-soundcloud').prop('checked'); ppOptions.option_embedding_soundcloud = $('#option-embedding-soundcloud').prop('checked');
ppOptions.option_embedding_soundcloud_orig_link = $('#option-embedding-soundcloud-orig-link').prop('checked'); ppOptions.option_embedding_soundcloud_orig_link = $('#option-embedding-soundcloud-orig-link').prop('checked');
ppOptions.option_embedding_pleercom = $('option-embedding-pleercom').prop('checked'); ppOptions.option_embedding_pleercom = $('#option-embedding-pleercom').prop('checked');
ppOptions.option_embedding_pleercom_nokita_server = $('#option-embedding-pleercom-nokita-server').prop('checked');
ppOptions.option_visual_editor_post = $('#option-visual-editor-post').prop('checked'); ppOptions.option_visual_editor_post = $('#option-visual-editor-post').prop('checked');
ppOptions.checkbox_search_with_google = $('#option-search-with-google').prop('checked'); ppOptions.checkbox_search_with_google = $('#option-search-with-google').prop('checked');
ppOptions.option_ws = $('#option-ws').prop('checked'); ppOptions.option_ws = $('#option-ws').prop('checked');
@ -78,7 +80,6 @@ function pp_save_options() {
ppOptions.option_other_hightlight_post_comments = $('#option-other-hightlight-post-comments').prop('checked'); ppOptions.option_other_hightlight_post_comments = $('#option-other-hightlight-post-comments').prop('checked');
ppOptions.option_other_show_recommendation_count = $('#option-other-show-recommendation-count').prop('checked'); ppOptions.option_other_show_recommendation_count = $('#option-other-show-recommendation-count').prop('checked');
// Saving parameters // Saving parameters
chrome.storage.sync.set(ppOptions, function() { chrome.storage.sync.set(ppOptions, function() {
// Update status to let user know options were saved. // Update status to let user know options were saved.
@ -100,8 +101,8 @@ function pp_restore_options() {
// Detecting option type // Detecting option type
if (typeof(value) == 'boolean') { if (typeof(value) == 'boolean') {
// Checkbox // Checkbox
optionId = '#' + key.replace(/_/g, '-');
if (value === true) { if (value === true) {
optionId = '#' + key.replace(/_/g, '-');
$(optionId).first().prop('checked', true); $(optionId).first().prop('checked', true);
} }
} else if (typeof(value) == 'number') { } else if (typeof(value) == 'number') {

View file

@ -35,7 +35,7 @@ $(document).ready(function() {
$player = $('<div class="pp-soundcloud">\ $player = $('<div class="pp-soundcloud">\
<object height="81" width="100%" id="pp-soundcloud-' + index + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">\ <object height="81" width="100%" id="pp-soundcloud-' + index + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">\
<param name="movie" value="http://player.soundcloud.com/player.swf?url=' + encodeURIComponent($(this).prop('href')) <param name="movie" value="http://player.soundcloud.com/player.swf?url=' + encodeURIComponent($(this).prop('href'))
+ '&enable_api=true&object_id=pp-soundcloud-' + index + '"></param>\ + '&enable_api=true&object_id=pp-soundcloud-' + index + '">\
<param name="allowscriptaccess" value="always">\ <param name="allowscriptaccess" value="always">\
<embed allowscriptaccess="always" height="81" src="http://player.soundcloud.com/player.swf?url=' <embed allowscriptaccess="always" height="81" src="http://player.soundcloud.com/player.swf?url='
+ encodeURIComponent($(this).prop('href')) + '&enable_api=true&object_id=pp-soundcloud-' + index + encodeURIComponent($(this).prop('href')) + '&enable_api=true&object_id=pp-soundcloud-' + index
@ -520,7 +520,6 @@ function create_image(domain, id, additional) {
/* point */ /* point */
// Эта часть написана @RainbowSpike // Эта часть написана @RainbowSpike
function mark_unread_post() { function mark_unread_post() {
// @todo Проверить работает ли
var divs = $(".post"); // массив постов var divs = $(".post"); // массив постов
for (var i = 0; i < divs.length; i++) { // обыск постов for (var i = 0; i < divs.length; i++) { // обыск постов
var spans = $(divs[i]).find(".unread"); // поиск метки непрочитанных комментов var spans = $(divs[i]).find(".unread"); // поиск метки непрочитанных комментов
@ -583,6 +582,7 @@ function set_posts_count_label() {
} }
var e1 = document.createElement('span'); 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', 'Количество комментаторов'); $(e1).addClass('authors_unique_count').html(answer.list[id].count_comment_unique).attr('title', 'Количество комментаторов');
postid.appendChild(e1); postid.appendChild(e1);
@ -597,6 +597,16 @@ function set_posts_count_label() {
} }
function parse_pleercom_links(){ 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) { $('a').each(function (num, obj) {
var href = obj.href; var href = obj.href;
var n = null; var n = null;
@ -607,11 +617,53 @@ function parse_pleercom_links() {
'src': 'https://api.kanaria.ru/point/get_pleer_file.php?id=' + n[1], 'src': 'https://api.kanaria.ru/point/get_pleer_file.php?id=' + n[1],
'controls': 'controls', 'controls': 'controls',
'preload': 'none' 'preload': 'none'
}).addClass('embeded_audio');
obj.parentElement.insertBefore(player, obj);
}
}); });
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,
'pleer_id':id,
'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);
}
});
} }

View file

@ -1,7 +1,7 @@
{ {
"manifest_version": 2, "manifest_version": 2,
"name": "Point+", "name": "Point+",
"version": "1.10.1", "version": "1.10.2",
"author": "Alexey Skobkin", "author": "Alexey Skobkin",
"homepage_url": "https://bitbucket.org/skobkin/chrome_point_plus", "homepage_url": "https://bitbucket.org/skobkin/chrome_point_plus",
"description": "More features for point.im", "description": "More features for point.im",

View file

@ -62,7 +62,11 @@
</div> </div>
<div class="option"> <div class="option">
<input type="checkbox" id="option-embedding-pleercom"><label for="option-embedding-pleercom">Pleer.com</label> <input type="checkbox" id="option-embedding-pleercom"><label for="option-embedding-pleercom">Pleer.com &#9660;</label>
<div class="option">
<input type="checkbox" id="option-embedding-pleercom-nokita-server"><label for="option-embedding-pleercom-nokita-server">Use Nokita's server</label>
</div>
</div> </div>
</div> </div>
</div> </div>