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 #13)
Четыре изменения, включая audio, coub и неделю Тойоты
This commit is contained in:
commit
48f49af2a4
|
@ -56,11 +56,20 @@
|
|||
"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_audios_parse_links": {
|
||||
"message": "Parse audio links and create audio instead"
|
||||
},
|
||||
"option_videos_parse_all_videos": {
|
||||
"message": "Parse all links to videos and create video instead"
|
||||
"option_videos_parse_links": {
|
||||
"message": "Parse video links 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": "Leave original link"
|
||||
},
|
||||
"option_embedding_soundcloud": {
|
||||
"message": "Soundcloud ▼"
|
||||
|
@ -74,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"
|
||||
},
|
||||
|
@ -132,7 +144,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)"
|
||||
|
|
|
@ -56,11 +56,20 @@
|
|||
"option_images_load_booru": {
|
||||
"message": "Загружать картинки с Booru, Tumblr и других сайтов"
|
||||
},
|
||||
"option_videos_parse_webm": {
|
||||
"message": "Оборачивать ссылки на webm в тег <video>"
|
||||
"option_audios_parse_links": {
|
||||
"message": "Превращать ссылки на аудио в аудио"
|
||||
},
|
||||
"option_videos_parse_all_videos": {
|
||||
"message": "Оборачивать ссылки на всё видео в тег <video>"
|
||||
"option_videos_parse_links": {
|
||||
"message": "Превращать ссылки на видео в видео"
|
||||
},
|
||||
"option_videos_parse_webm": {
|
||||
"message": "Только webm"
|
||||
},
|
||||
"option_videos_parse_all_links": {
|
||||
"message": "Все ссылки на видео"
|
||||
},
|
||||
"option_videos_parse_leave_links": {
|
||||
"message": "Оставлять ссылку на видео"
|
||||
},
|
||||
"option_embedding_soundcloud": {
|
||||
"message": "Soundcloud ▼"
|
||||
|
@ -74,6 +83,9 @@
|
|||
"option_embedding_pleercom_nokita_server": {
|
||||
"message": "Использовать сервер @NokitaKaze вместо AJAX-запроса для получения mp3"
|
||||
},
|
||||
"option_embedding_coubcom": {
|
||||
"message": "Coub.com ▼"
|
||||
},
|
||||
"option_nsfw": {
|
||||
"message": "Фильтрация NSFW-контента"
|
||||
},
|
||||
|
@ -132,7 +144,7 @@
|
|||
"message": "Пёс перед юзернеймом"
|
||||
},
|
||||
"option_other_hightlight_post_comments": {
|
||||
"message": "Подсвечивать посты с новыми комментариями (используя сервер @NokitaKaze)"
|
||||
"message": "Подсвечивать посты с новыми комментариями"
|
||||
},
|
||||
"option_other_show_recommendation_count": {
|
||||
"message": "Показывать количество рекомендаций и уникальных комментаторов в посте (используя сервер @NokitaKaze)"
|
||||
|
|
|
@ -26,10 +26,11 @@ $(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);
|
||||
|
||||
// Options debug
|
||||
try {
|
||||
console.debug('Options loaded: %O', options);
|
||||
}catch(e){}
|
||||
create_tag_system();
|
||||
|
||||
// Embedding
|
||||
|
@ -38,15 +39,21 @@ $(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_webm.value == true) {
|
||||
if (options.option_videos_parse_all_videos.value == true) {
|
||||
parse_all_videos();
|
||||
if (options.option_videos_parse_links.value == true) {
|
||||
if (options.option_videos_parse_links_type.value == "all") {
|
||||
parse_all_videos(options);
|
||||
} else {
|
||||
parse_webm();
|
||||
parse_webm(options);
|
||||
}
|
||||
}
|
||||
|
||||
// Parse audio links
|
||||
if (options.option_audios_parse_links.value == true) {
|
||||
parse_all_audios(options);
|
||||
}
|
||||
|
||||
// Soundcloud
|
||||
if (options.option_embedding_soundcloud.value == true) {
|
||||
// Injecting JS API
|
||||
|
@ -82,9 +89,15 @@ $(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();
|
||||
parse_pleercom_links(options);
|
||||
}
|
||||
|
||||
// Parse coub.com links and create iframe instead
|
||||
if (options.option_embedding_coubcom.value == true) {
|
||||
parse_coub_links(options);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -186,15 +199,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
|
||||
|
@ -546,11 +559,10 @@ var months = [
|
|||
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
|
||||
];
|
||||
|
||||
|
||||
// Картинки с бурятников
|
||||
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,8 +664,8 @@ function mark_unread_post() {
|
|||
}
|
||||
|
||||
// Webm
|
||||
function parse_webm() {
|
||||
$('a').each(function(num, obj) {
|
||||
function parse_webm(current_options) {
|
||||
$('.post-content a').each(function(num, obj) {
|
||||
if ($(obj).hasClass('booru_pic')) {
|
||||
return;
|
||||
}
|
||||
|
@ -670,12 +682,17 @@ 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) {
|
||||
// Видео
|
||||
function parse_all_videos(current_options) {
|
||||
$('.post-content a').each(function(num, obj) {
|
||||
if ($(obj).hasClass('booru_pic')) {
|
||||
return;
|
||||
}
|
||||
|
@ -686,12 +703,16 @@ 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('<source src="' + href + '" type=\'' + mime + '"\' />').attr('controls', 'controls').css({
|
||||
$(player).html('<source src="' + href + '" type=\'' + mime + '\' />').attr('controls', 'controls').css({
|
||||
'display': 'block',
|
||||
'max-width': '95%'
|
||||
}).addClass('parsed-webm-link');
|
||||
|
||||
obj.parentElement.insertBefore(player, obj);
|
||||
|
||||
if (current_options.option_videos_parse_leave_links.value == false) {
|
||||
$(obj).hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -704,7 +725,53 @@ function video_extension_to_mime(extension) {
|
|||
case 'mpg' :return 'video/mp4;';
|
||||
case 'mpeg':return 'video/mp4;';
|
||||
}
|
||||
}
|
||||
|
||||
// Аудио
|
||||
function parse_all_audios(current_options){
|
||||
$('.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 (typeof(n[3])=='undefined'){
|
||||
return;
|
||||
}
|
||||
if (!n[3].match('extra\\=', 'i')){
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var player = document.createElement('audio');
|
||||
var mime = audio_extension_to_mime(n[2]);
|
||||
$(player).html('<source src="' + href + '" type=\'' + mime + '\' />').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';
|
||||
}
|
||||
}
|
||||
|
||||
// Плашки у постов
|
||||
|
@ -751,18 +818,16 @@ 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(current_options) {
|
||||
if (current_options.option_embedding_pleercom_nokita_server.value) {
|
||||
parse_pleercom_links_nokita();
|
||||
} else {
|
||||
parse_pleercom_links_ajax(current_options);
|
||||
}
|
||||
}
|
||||
|
||||
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,27 +848,29 @@ function parse_pleercom_links_nokita() {
|
|||
});
|
||||
}
|
||||
|
||||
function parse_pleercom_links_ajax() {
|
||||
$('a').each(function(num, 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]);
|
||||
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);
|
||||
|
@ -815,9 +882,13 @@ function create_pleercom_ajax(id) {
|
|||
'preload': 'auto'
|
||||
});
|
||||
$('.embeded_audio_' + this.settings.pleer_id)[0].appendChild(player);
|
||||
|
||||
if (this.settings.current_options.option_embedding_pleercom_orig_link.value == false){
|
||||
$('.pleercom_original_link_'+this.settings.pleer_id).hide();
|
||||
}
|
||||
},
|
||||
'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);
|
||||
}
|
||||
|
||||
|
@ -949,3 +1020,32 @@ function draft_save_check() {
|
|||
}, 1000);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Парсим ссылки на coub
|
||||
function parse_coub_links(current_options) {
|
||||
$('.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();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -50,10 +50,23 @@
|
|||
</div>
|
||||
|
||||
<div class="option-node">
|
||||
<input type="checkbox" class="option-boolean" id="option-videos-parse-webm"><label for="option-videos-parse-webm" data-i18n="option_videos_parse_webm"></label>
|
||||
<input type="checkbox" class="option-boolean" id="option-videos-parse-links"><label for="option-videos-parse-links" data-i18n="option_videos_parse_links"></label>
|
||||
|
||||
<div class="option-node">
|
||||
<input type="checkbox" class="option-boolean" id="option-videos-parse-all-videos"><label for="option-videos-parse-all-videos" data-i18n="option_videos_parse_all_videos"></label>
|
||||
<input type="radio" class="option-enum" name="option-videos-parse-links-type" id="option-videos-parse-webm" value="webm" ><label for="option-videos-parse-webm" data-i18n="option_videos_parse_webm"></label>
|
||||
<input type="radio" class="option-enum" name="option-videos-parse-links-type" id="option-videos-parse-all-links" value="all" checked="checked"><label for="option-videos-parse-all-links" data-i18n="option_videos_parse_all_links"></label>
|
||||
</div>
|
||||
|
||||
<div class="option-node">
|
||||
<input type="checkbox" class="option-boolean" id="option-videos-parse-leave-links"><label for="option-videos-parse-leave-links" data-i18n="option_videos_parse_leave_links"></label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="option-node">
|
||||
<input type="checkbox" class="option-boolean" id="option-audios-parse-links"><label for="option-audios-parse-links" data-i18n="option_audios_parse_links"></label>
|
||||
|
||||
<div class="option-node">
|
||||
<input type="checkbox" class="option-boolean" id="option-audios-parse-leave-links"><label for="option-audios-parse-leave-links" data-i18n="option_embedding_soundcloud_orig_link"></label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -71,6 +84,18 @@
|
|||
<div class="option-node">
|
||||
<input type="checkbox" class="option-boolean" id="option-embedding-pleercom-nokita-server"><label for="option-embedding-pleercom-nokita-server" data-i18n="option_embedding_pleercom_nokita_server"></label>
|
||||
</div>
|
||||
|
||||
<div class="option-node">
|
||||
<input type="checkbox" class="option-boolean" id="option-embedding-pleercom-orig-link"><label for="option-embedding-pleercom-orig-link" data-i18n="option_embedding_soundcloud_orig_link"></label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="option-node">
|
||||
<input type="checkbox" class="option-boolean" id="option-embedding-coubcom"><label for="option-embedding-coubcom" data-i18n="option_embedding_coubcom"></label>
|
||||
|
||||
<div class="option-node">
|
||||
<input type="checkbox" class="option-boolean" id="option-embedding-coubcom-orig-link"><label for="option-embedding-coubcom-orig-link" data-i18n="option_embedding_soundcloud_orig_link"></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in a new issue