mirror of
https://bitbucket.org/skobkin/chrome_point_plus.git
synced 2024-11-23 18:56:04 +00:00
Merged in NokitaKaze/chrome_point_plus-nokita-version (pull request #6)
Pleer.com
This commit is contained in:
commit
320869316e
|
@ -180,4 +180,3 @@ div#markItUpText-input {
|
||||||
margin-left: 0.2em;
|
margin-left: 0.2em;
|
||||||
background: #f2eceb;
|
background: #f2eceb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,10 @@ function $ajax_prot(settings){
|
||||||
if (settings['async'] !==undefined){this.async =settings['async'];}
|
if (settings['async'] !==undefined){this.async =settings['async'];}
|
||||||
if (settings['type'] !==undefined){this.type =settings['type'];}
|
if (settings['type'] !==undefined){this.type =settings['type'];}
|
||||||
if (settings['postdata']!==undefined){this.postdata=settings['postdata'];}
|
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=new XMLHttpRequest();
|
||||||
this.xhr.parent =this;
|
this.xhr.parent =this;
|
||||||
this.xhr.settings=settings;
|
this.xhr.settings=settings;
|
||||||
|
@ -12,7 +15,9 @@ function $ajax_prot(settings){
|
||||||
this.xhr.error =settings['error'];
|
this.xhr.error =settings['error'];
|
||||||
this.xhr.onreadystatechange=this.change;
|
this.xhr.onreadystatechange=this.change;
|
||||||
this.xhr.open(this.type, this.url, this.async);
|
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){
|
if (settings.headers!==undefined){
|
||||||
for (var i=0;i<settings.headers.length;i++){
|
for (var i=0;i<settings.headers.length;i++){
|
||||||
this.xhr.setRequestHeader(settings.headers[i][0], settings.headers[i][1]);
|
this.xhr.setRequestHeader(settings.headers[i][0], settings.headers[i][1]);
|
||||||
|
@ -22,12 +27,13 @@ function $ajax_prot(settings){
|
||||||
}
|
}
|
||||||
|
|
||||||
$ajax_prot.prototype={
|
$ajax_prot.prototype={
|
||||||
version: '0.0.4a',
|
version: '0.0.5a',
|
||||||
url: '',
|
url: '',
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
async: true,
|
async: true,
|
||||||
postdata:null,
|
postdata:null,
|
||||||
xhr: null,
|
xhr: null,
|
||||||
|
dont_set_content_type: false,
|
||||||
change:function(){
|
change:function(){
|
||||||
if (this.readyState!==4){return;}
|
if (this.readyState!==4){return;}
|
||||||
if (this.status==200){
|
if (this.status==200){
|
||||||
|
|
|
@ -22,6 +22,9 @@ var ppOptions = [
|
||||||
// SoundCloud
|
// SoundCloud
|
||||||
'option_embedding_soundcloud',
|
'option_embedding_soundcloud',
|
||||||
'option_embedding_soundcloud_orig_link',
|
'option_embedding_soundcloud_orig_link',
|
||||||
|
// Pleer.com
|
||||||
|
'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
|
||||||
|
@ -60,6 +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_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');
|
||||||
|
@ -75,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.
|
||||||
|
@ -97,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') {
|
||||||
|
|
|
@ -12,13 +12,14 @@ $(document).ready(function() {
|
||||||
// Embedding
|
// Embedding
|
||||||
if (options.option_embedding == true) {
|
if (options.option_embedding == true) {
|
||||||
// Load pictures from Booru, Tumblr and some other sites
|
// Load pictures from Booru, Tumblr and some other sites
|
||||||
if (options.option_images_load_booru == true){
|
if (options.option_images_load_booru == true) {
|
||||||
load_all_booru_images();
|
load_all_booru_images();
|
||||||
}
|
}
|
||||||
// Parse webm-links and create video instead
|
// Parse webm-links and create video instead
|
||||||
if (options.option_videos_parse_webm == true){
|
if (options.option_videos_parse_webm == true) {
|
||||||
parse_webm();
|
parse_webm();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Soundcloud
|
// Soundcloud
|
||||||
if (options.option_embedding_soundcloud == true) {
|
if (options.option_embedding_soundcloud == true) {
|
||||||
// Injecting JS API
|
// Injecting JS API
|
||||||
|
@ -26,22 +27,22 @@ $(document).ready(function() {
|
||||||
type: 'injectJSFile',
|
type: 'injectJSFile',
|
||||||
file: 'js/soundcloud/soundcloud.player.api.js'
|
file: 'js/soundcloud/soundcloud.player.api.js'
|
||||||
});
|
});
|
||||||
|
|
||||||
// Processing links
|
// Processing links
|
||||||
$('.post .post-content a[href*="\\:\\/\\/soundcloud\\.com\\/"]').each(function(index) {
|
$('.post .post-content a[href*="\\:\\/\\/soundcloud\\.com\\/"]').each(function (index) {
|
||||||
console.log($(this));
|
console.log($(this));
|
||||||
|
|
||||||
$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>\
|
<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
|
||||||
+ '" type="application/x-shockwave-flash" width="100%" name="pp-soundcloud-' + index + '"></embed>\
|
+ '" type="application/x-shockwave-flash" width="100%" name="pp-soundcloud-' + index + '"></embed>\
|
||||||
</object>\
|
</object>\
|
||||||
</div>');
|
</div>');
|
||||||
|
|
||||||
// Replace or prepend
|
// Replace or prepend
|
||||||
if (options.option_embedding_soundcloud_orig_link == true) {
|
if (options.option_embedding_soundcloud_orig_link == true) {
|
||||||
// Before
|
// Before
|
||||||
|
@ -51,6 +52,11 @@ $(document).ready(function() {
|
||||||
$(this).replaceWith($player);
|
$(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 */
|
/* 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"); // поиск метки непрочитанных комментов
|
||||||
|
@ -577,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);
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "Point+",
|
"name": "Point+",
|
||||||
"version": "1.10.0",
|
"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",
|
||||||
|
@ -52,6 +52,7 @@
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"http://*.point.im/*",
|
"http://*.point.im/*",
|
||||||
"https://*.point.im/*",
|
"https://*.point.im/*",
|
||||||
|
"https://pleer.com/*",
|
||||||
"storage",
|
"storage",
|
||||||
"notifications",
|
"notifications",
|
||||||
"tabs"
|
"tabs"
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
<div class="option">
|
<div class="option">
|
||||||
<input type="checkbox" id="option-videos-parse-webm"><label for="option-videos-parse-webm">Parse webm-links and create video instead</label>
|
<input type="checkbox" id="option-videos-parse-webm"><label for="option-videos-parse-webm">Parse webm-links and create video instead</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="option">
|
<div class="option">
|
||||||
<input type="checkbox" id="option-embedding-soundcloud"><label for="option-embedding-soundcloud">Soundcloud ▼</label>
|
<input type="checkbox" id="option-embedding-soundcloud"><label for="option-embedding-soundcloud">Soundcloud ▼</label>
|
||||||
|
|
||||||
|
@ -60,6 +60,14 @@
|
||||||
<input type="checkbox" id="option-embedding-soundcloud-orig-link"><label for="option-embedding-soundcloud-orig-link">Leave original link</label>
|
<input type="checkbox" id="option-embedding-soundcloud-orig-link"><label for="option-embedding-soundcloud-orig-link">Leave original link</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="option">
|
||||||
|
<input type="checkbox" id="option-embedding-pleercom"><label for="option-embedding-pleercom">Pleer.com ▼</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>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue