Merged in NokitaKaze/chrome_point_plus-nokita-version (pull request #9)

Шесть изменений
This commit is contained in:
Alexey Skobkin 2014-11-23 11:51:36 +03:00
commit dcf7346078
7 changed files with 440 additions and 137 deletions

View file

@ -56,6 +56,9 @@
"option_videos_parse_webm": { "option_videos_parse_webm": {
"message": "Parse webm-links and create video instead" "message": "Parse webm-links and create video instead"
}, },
"option_videos_parse_all_videos": {
"message": "Parse all links to videos and create video instead"
},
"option_embedding_soundcloud": { "option_embedding_soundcloud": {
"message": "Soundcloud ▼" "message": "Soundcloud ▼"
}, },
@ -71,11 +74,20 @@
"option_nsfw": { "option_nsfw": {
"message": "NSFW content filtering" "message": "NSFW content filtering"
}, },
"option_nsfw_blur": { "option_nsfw_hide_posts":{
"message": "Blurring" "message": "Hide posts with `nsfw` tag from feed"
}, },
"option_nsfw_blur_comments": { "option_nsfw_blur_posts_images": {
"message": "Blur comments too" "message": "Blur images in nsfw posts"
},
"option_nsfw_blur_posts_entire": {
"message": "Blur entire nsfw posts"
},
"option_nsfw_blur_comments_images": {
"message": "Blur images in comments in nsfw posts"
},
"option_nsfw_blur_comments_entire": {
"message": "Blur entire comments in nsfw posts"
}, },
"option_ctrl_enter": { "option_ctrl_enter": {
"message": "Send post and comments by CTRL+Enter (deprecated)" "message": "Send post and comments by CTRL+Enter (deprecated)"
@ -123,6 +135,9 @@
"message": "Show recommendation count and unique commentators count (using @NokitaKaze server)" "message": "Show recommendation count and unique commentators count (using @NokitaKaze server)"
}, },
"option_other_scroll_space_key":{
"message": "Scrolling posts with `space` key"
},
"options_feedback_text": { "options_feedback_text": {
"message": "<p>If you find an error do not hesitate to <a href=\"https:\/\/bitbucket.org\/skobkin\/chrome_point_plus\/issues?status=new&status=open\" target=\"_blank\">send me a bug report<\/a>.<\/p><p>Also you can make a donation in the following ways:<\/p><p><iframe frameborder=\"0\" allowtransparency=\"true\" scrolling=\"no\" src=\"https:\/\/money.yandex.ru\/embed\/small.xml?account=41001539215836&quickpay=small&yamoney-payment-type=on&button-text=04&button-size=s&button-color=black&targets=Point%2B&default-sum=150&successURL=https%3A%2F%2Fbitbucket.org%2Fskobkin%2Fchrome_point_plus\" width=\"158\" height=\"31\"><\/p><p><\/iframe><\/p><p><iframe frameborder=\"0\" allowtransparency=\"true\" scrolling=\"no\" src=\"https:\/\/money.yandex.ru\/embed\/small.xml?account=41001539215836&quickpay=small&any-card-payment-type=on&button-text=04&button-size=s&button-color=black&targets=Point%2B&default-sum=150&successURL=https%3A%2F%2Fbitbucket.org%2Fskobkin%2Fchrome_point_plus\" width=\"158\" height=\"31\"><\/iframe><\/p><p><form action=\"https:\/\/www.paypal.com\/cgi-bin\/webscr\" method=\"post\" target=\"_top\"><input type=\"hidden\" name=\"cmd\" value=\"_s-xclick\"><input type=\"hidden\" name=\"hosted_button_id\" value=\"RCW5V6UFXYTRE\"><input type=\"image\" src=\"https:\/\/www.paypalobjects.com\/ru_RU\/RU\/i\/btn\/btn_donateCC_LG.gif\" border=\"0\" name=\"submit\" alt=\"PayPal — более безопасный и легкий способ оплаты через Интернет!\"><img alt=\"\" border=\"0\" src=\"https:\/\/www.paypalobjects.com\/en_US\/i\/scr\/pixel.gif\" width=\"1\" height=\"1\"><\/form><\/p>" "message": "<p>If you find an error do not hesitate to <a href=\"https:\/\/bitbucket.org\/skobkin\/chrome_point_plus\/issues?status=new&status=open\" target=\"_blank\">send me a bug report<\/a>.<\/p><p>Also you can make a donation in the following ways:<\/p><p><iframe frameborder=\"0\" allowtransparency=\"true\" scrolling=\"no\" src=\"https:\/\/money.yandex.ru\/embed\/small.xml?account=41001539215836&quickpay=small&yamoney-payment-type=on&button-text=04&button-size=s&button-color=black&targets=Point%2B&default-sum=150&successURL=https%3A%2F%2Fbitbucket.org%2Fskobkin%2Fchrome_point_plus\" width=\"158\" height=\"31\"><\/p><p><\/iframe><\/p><p><iframe frameborder=\"0\" allowtransparency=\"true\" scrolling=\"no\" src=\"https:\/\/money.yandex.ru\/embed\/small.xml?account=41001539215836&quickpay=small&any-card-payment-type=on&button-text=04&button-size=s&button-color=black&targets=Point%2B&default-sum=150&successURL=https%3A%2F%2Fbitbucket.org%2Fskobkin%2Fchrome_point_plus\" width=\"158\" height=\"31\"><\/iframe><\/p><p><form action=\"https:\/\/www.paypal.com\/cgi-bin\/webscr\" method=\"post\" target=\"_top\"><input type=\"hidden\" name=\"cmd\" value=\"_s-xclick\"><input type=\"hidden\" name=\"hosted_button_id\" value=\"RCW5V6UFXYTRE\"><input type=\"image\" src=\"https:\/\/www.paypalobjects.com\/ru_RU\/RU\/i\/btn\/btn_donateCC_LG.gif\" border=\"0\" name=\"submit\" alt=\"PayPal — более безопасный и легкий способ оплаты через Интернет!\"><img alt=\"\" border=\"0\" src=\"https:\/\/www.paypalobjects.com\/en_US\/i\/scr\/pixel.gif\" width=\"1\" height=\"1\"><\/form><\/p>"

View file

@ -56,6 +56,9 @@
"option_videos_parse_webm": { "option_videos_parse_webm": {
"message": "Оборачивать ссылки на webm в тег &#60;video&#62;" "message": "Оборачивать ссылки на webm в тег &#60;video&#62;"
}, },
"option_videos_parse_all_videos": {
"message": "Оборачивать ссылки на всё видео в тег &#60;video&#62;"
},
"option_embedding_soundcloud": { "option_embedding_soundcloud": {
"message": "Soundcloud &#9660;" "message": "Soundcloud &#9660;"
}, },
@ -71,11 +74,20 @@
"option_nsfw": { "option_nsfw": {
"message": "Фильтрация NSFW-контента" "message": "Фильтрация NSFW-контента"
}, },
"option_nsfw_blur": { "option_nsfw_hide_posts":{
"message": "Размытие небезопасных постов" "message": "Скрывать NSFW-посты из ленты сообщений"
}, },
"option_nsfw_blur_comments": { "option_nsfw_blur_posts_images": {
"message": "Размытие комментариев" "message": "Размытие картинок в небезопасных постах"
},
"option_nsfw_blur_posts_entire": {
"message": "Размытие небезопасных постов полностью"
},
"option_nsfw_blur_comments_images": {
"message": "Размытие картинок в каментариях небезопасных постов"
},
"option_nsfw_blur_comments_entire": {
"message": "Размытие ВСЕХ комментариев в небезопасных постах"
}, },
"option_ctrl_enter": { "option_ctrl_enter": {
"message": "Отправлять текст по CTRL+Enter (устарело)" "message": "Отправлять текст по CTRL+Enter (устарело)"
@ -123,6 +135,10 @@
"message": "Показывать количество рекомендаций и уникальных комментаторов в посте (используя сервер @NokitaKaze)" "message": "Показывать количество рекомендаций и уникальных комментаторов в посте (используя сервер @NokitaKaze)"
}, },
"option_other_scroll_space_key":{
"message": "Скроллинг постов пробелом"
},
"options_feedback_text": { "options_feedback_text": {
"message": "<p>Нашли ошибку? Не стесняйтесь <a href=\"https:\/\/bitbucket.org\/skobkin\/chrome_point_plus\/issues?status=new&status=open\" target=\"_blank\">сообщить о ней<\/a>.<\/p><p>Также вы можете сделать пожертвование автору:<\/p><p><iframe frameborder=\"0\" allowtransparency=\"true\" scrolling=\"no\" src=\"https:\/\/money.yandex.ru\/embed\/small.xml?account=41001539215836&quickpay=small&yamoney-payment-type=on&button-text=04&button-size=s&button-color=black&targets=Point%2B&default-sum=150&successURL=https%3A%2F%2Fbitbucket.org%2Fskobkin%2Fchrome_point_plus\" width=\"158\" height=\"31\"><\/iframe><\/p><p><iframe frameborder=\"0\" allowtransparency=\"true\" scrolling=\"no\" src=\"https:\/\/money.yandex.ru\/embed\/small.xml?account=41001539215836&quickpay=small&any-card-payment-type=on&button-text=04&button-size=s&button-color=black&targets=Point%2B&default-sum=150&successURL=https%3A%2F%2Fbitbucket.org%2Fskobkin%2Fchrome_point_plus\" width=\"158\" height=\"31\"><\/iframe><\/p><p><form action=\"https:\/\/www.paypal.com\/cgi-bin\/webscr\" method=\"post\" target=\"_top\"><input type=\"hidden\" name=\"cmd\" value=\"_s-xclick\"><input type=\"hidden\" name=\"hosted_button_id\" value=\"WW33X5J5WFSP4\"><input type=\"image\" src=\"https:\/\/www.paypalobjects.com\/ru_RU\/RU\/i\/btn\/btn_donateCC_LG.gif\" border=\"0\" name=\"submit\" alt=\"PayPal — более безопасный и легкий способ оплаты через Интернет!\"><img alt=\"\" border=\"0\" src=\"https:\/\/www.paypalobjects.com\/en_US\/i\/scr\/pixel.gif\" width=\"1\" height=\"1\"><\/form><\/p>" "message": "<p>Нашли ошибку? Не стесняйтесь <a href=\"https:\/\/bitbucket.org\/skobkin\/chrome_point_plus\/issues?status=new&status=open\" target=\"_blank\">сообщить о ней<\/a>.<\/p><p>Также вы можете сделать пожертвование автору:<\/p><p><iframe frameborder=\"0\" allowtransparency=\"true\" scrolling=\"no\" src=\"https:\/\/money.yandex.ru\/embed\/small.xml?account=41001539215836&quickpay=small&yamoney-payment-type=on&button-text=04&button-size=s&button-color=black&targets=Point%2B&default-sum=150&successURL=https%3A%2F%2Fbitbucket.org%2Fskobkin%2Fchrome_point_plus\" width=\"158\" height=\"31\"><\/iframe><\/p><p><iframe frameborder=\"0\" allowtransparency=\"true\" scrolling=\"no\" src=\"https:\/\/money.yandex.ru\/embed\/small.xml?account=41001539215836&quickpay=small&any-card-payment-type=on&button-text=04&button-size=s&button-color=black&targets=Point%2B&default-sum=150&successURL=https%3A%2F%2Fbitbucket.org%2Fskobkin%2Fchrome_point_plus\" width=\"158\" height=\"31\"><\/iframe><\/p><p><form action=\"https:\/\/www.paypal.com\/cgi-bin\/webscr\" method=\"post\" target=\"_top\"><input type=\"hidden\" name=\"cmd\" value=\"_s-xclick\"><input type=\"hidden\" name=\"hosted_button_id\" value=\"WW33X5J5WFSP4\"><input type=\"image\" src=\"https:\/\/www.paypalobjects.com\/ru_RU\/RU\/i\/btn\/btn_donateCC_LG.gif\" border=\"0\" name=\"submit\" alt=\"PayPal — более безопасный и легкий способ оплаты через Интернет!\"><img alt=\"\" border=\"0\" src=\"https:\/\/www.paypalobjects.com\/en_US\/i\/scr\/pixel.gif\" width=\"1\" height=\"1\"><\/form><\/p>"

View file

@ -173,14 +173,60 @@ div#markItUpText-input {
} }
/* Labels in post */ /* Labels in post */
.post .post-id a .authors_unique_count, .post .post-id a .recomendation_count { .post .post-id a .cn.changed_background{
}
.post .post-id a .authors_unique_count, .post .post-id a .recommendation_count {
padding: 0 .5em; padding: 0 .5em;
font-weight: normal; font-weight: normal;
color: #35587c; color: #35587c;
background: #f2f2eb; background-color: #f2f2eb;
} }
.post .post-id a .recomendation_count { .post .post-id a .recommendation_count {
margin-left: 0.2em; margin-left: 0.2em;
background: #f2eceb; background-color: #f2eceb;
} }
/* NSFW-content */
.post-tag-nsfw.blur-nsfw-images a.postimg img,
.post-tag-сиськи.blur-nsfw-images a.postimg img,
#comments.blur-nsfw-images a.postimg img{
margin-top: 5px;
-webkit-filter: blur(30px);
}
.post-tag-nsfw.blur-nsfw-images a.postimg:hover img,
.post-tag-сиськи.blur-nsfw-images a.postimg:hover img,
#comments.blur-nsfw-images a.postimg:hover img{
-webkit-filter: none;
}
.post-tag-nsfw.hide-nsfw-posts,
.post-tag-сиськи.hide-nsfw-posts{
display: none;
}
.post-tag-nsfw.blur-nsfw-entire .post-content .text,
.post-tag-сиськи.blur-nsfw-entire .post-content .text,
#comments.blur-nsfw-entire .post-content .text{
-webkit-filter: blur(30px);
}
/* point-plus-debug */
.point-plus-debug{
position: absolute;
padding: 10px 20px;
top: 60px;
left: 20px;
border-radius: 3px;
border: 1px solid #333;/* @todo Сделать не такой галимый */
background-color: #ddd;/* @todo Аналогично */
z-index: 11;
}
.post-tag-nsfw.hide-nsfw-posts,
.post-tag-сиськи.hide-nsfw-posts{
display: none;
}

View file

@ -17,6 +17,7 @@ var ppOptions = [
'option_images_load_booru', 'option_images_load_booru',
// Wrap WEBM videos into the <video> tag // Wrap WEBM videos into the <video> tag
'option_videos_parse_webm', 'option_videos_parse_webm',
'option_videos_parse_all_videos',
// SoundCloud // SoundCloud
'option_embedding_soundcloud', 'option_embedding_soundcloud',
'option_embedding_soundcloud_orig_link', 'option_embedding_soundcloud_orig_link',
@ -25,10 +26,13 @@ var ppOptions = [
'option_embedding_pleercom_nokita_server', 'option_embedding_pleercom_nokita_server',
// NSFW filtering // NSFW filtering
'option_nsfw', 'option_nsfw',
'option_nsfw_hide_posts',
// Blured pictures // Blured pictures
'option_nsfw_blur', 'option_nsfw_blur_posts_images',
// Blur comments too 'option_nsfw_blur_posts_entire',
'option_nsfw_blur_comments', // Blur comments too
'option_nsfw_blur_comments_images',
'option_nsfw_blur_comments_entire',
// CTRL+Enter // CTRL+Enter
'option_ctrl_enter', 'option_ctrl_enter',
// Fluid layout // Fluid layout
@ -51,6 +55,8 @@ var ppOptions = [
'option_other_hightlight_post_comments', 'option_other_hightlight_post_comments',
// Show recommendations and unique comments count // Show recommendations and unique comments count
'option_other_show_recommendation_count', 'option_other_show_recommendation_count',
// Scrolling posts with `space` key
'option_other_scroll_space_key',
]; ];
// Saves options to localStorage. // Saves options to localStorage.
@ -67,13 +73,17 @@ function pp_save_options() {
ppOptions.option_embedding = $('#option-embedding').prop('checked'); ppOptions.option_embedding = $('#option-embedding').prop('checked');
ppOptions.option_images_load_booru = $('#option-images-load-booru').prop('checked'); ppOptions.option_images_load_booru = $('#option-images-load-booru').prop('checked');
ppOptions.option_videos_parse_webm = $('#option-videos-parse-webm').prop('checked'); ppOptions.option_videos_parse_webm = $('#option-videos-parse-webm').prop('checked');
ppOptions.option_videos_parse_all_videos = $('#option-videos-parse-all-videos').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_embedding_pleercom_nokita_server = $('#option-embedding-pleercom-nokita-server').prop('checked');
ppOptions.option_nsfw = $('#option-nsfw').prop('checked'); ppOptions.option_nsfw = $('#option-nsfw').prop('checked');
ppOptions.option_nsfw_blur = $('#option-nsfw-blur').prop('checked'); ppOptions.option_nsfw_hide_posts = $('#option-nsfw-hide-posts').prop('checked');
ppOptions.option_nsfw_blur_comments = $('#option-nsfw-blur-comments').prop('checked'); ppOptions.option_nsfw_blur_posts_images = $('#option-nsfw-blur-posts-images').prop('checked');
ppOptions.option_nsfw_blur_posts_entire = $('#option-nsfw-blur-posts-entire').prop('checked');
ppOptions.option_nsfw_blur_comments_images = $('#option-nsfw-blur-comments-images').prop('checked');
ppOptions.option_nsfw_blur_comments_entire = $('#option-nsfw-blur-comments-entire').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');
@ -88,6 +98,8 @@ function pp_save_options() {
ppOptions.option_at_before_username = $('#option-at-before-username').prop('checked'); ppOptions.option_at_before_username = $('#option-at-before-username').prop('checked');
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');
ppOptions.option_other_scroll_space_key = $('#option-other-scroll-space-key').prop('checked');
// Saving parameters // Saving parameters
chrome.storage.sync.set(ppOptions, function() { chrome.storage.sync.set(ppOptions, function() {

View file

@ -1,14 +1,29 @@
$(document).ready(function() { $(document).ready(function () {
// Grouping console log // Grouping console log
console.group('point-plus'); console.group('point-plus');
console.info('Point+ %s', getVersion()); console.info('Point+ %s', getVersion());
// Проверяем, загрузились ли мы
var point_plus_debug=$('.point-plus-debug');
if (point_plus_debug.length>0){
console.info('Point+ already loaded, version: %s', point_plus_debug.attr('data-point-plus-version'));
return;
}
point_plus_debug=null;
var new_div=document.createElement('div');
document.body.appendChild(new_div);
$(new_div).attr({
'data-point-plus-version':getVersion()
}).addClass('point-plus-debug').html('Point+ v'+getVersion()+' loading...');
new_div=null;
// Loading options // Loading options
chrome.storage.sync.get(ppOptions, function(options) { chrome.storage.sync.get(ppOptions, function (options) {
// Options debug // Options debug
console.debug('Options loaded: %O', options); console.debug('Options loaded: %O', options);
create_tag_system();
// 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
@ -17,7 +32,11 @@ $(document).ready(function() {
} }
// 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(); if (options.option_videos_parse_all_videos == true) {
parse_all_videos();
} else {
parse_webm();
}
} }
// Soundcloud // Soundcloud
@ -62,19 +81,19 @@ $(document).ready(function() {
// Fancybox // Fancybox
if (options.option_fancybox == true) { if (options.option_fancybox == true) {
if (options.option_fancybox_bind_images_to_one_flow==true){ if (options.option_fancybox_bind_images_to_one_flow == true) {
// Linking images in posts to the galleries // Linking images in posts to the galleries
$('.post-content .text').each(function () { $('.post-content .text').each(function () {
$(this).find('a.postimg:not(.youtube)').attr('rel', 'one_flow_gallery'); $(this).find('a.postimg:not(.youtube)').attr('data-fancybox-group', 'one_flow_gallery');
}); });
} }
// Images // Images
if (options.option_fancybox_images == true) { if (options.option_fancybox_images == true) {
if (options.option_fancybox_bind_images_to_one_flow!==true) { if (options.option_fancybox_bind_images_to_one_flow !== true) {
// Linking images in posts to the galleries // Linking images in posts to the galleries
$('.post-content .text').each(function (idxPost) { $('.post-content .text').each(function (idxPost) {
$(this).find('a.postimg:not(.youtube)').attr('rel', 'post' + idxPost); $(this).find('a.postimg:not(.youtube)').attr('data-fancybox-group', 'post' + idxPost);
}); });
} }
// Init fancybox // Init fancybox
@ -82,6 +101,50 @@ $(document).ready(function() {
type: 'image' type: 'image'
}); });
} }
// Правим хинт в FancyBox
$('.post').each(function () {
var all_post_images = $(this).find('.postimg');
if (all_post_images.length == 0) {
return;
}
var tags = $(this).find('div.tags a.tag');
var hint_text = '';// Текст для хинта в FancyBox
// Сначала теги
for (var i = 0; i < tags.length; i++) {
var tag_name = $(tags[i]).html().toLowerCase();
hint_text += ' ' + tag_name;
}
// Потом текст
var textcontent = $(this).find('.text-content');
if (textcontent.length > 0) {
textcontent = textcontent[0];
for (var i = 0; i < textcontent.childNodes.length; i++) {
var current_child_node = textcontent.childNodes[i];
if ((current_child_node.nodeName !== 'P') && (current_child_node.nodeName !== '#text')) {
continue;
}
var a = $(current_child_node).find('a.postimg');
if (a.length > 0) {
continue;
}
var tmp_str = current_child_node.textContent.replace(/(\n(\r)?)/g, ' ');
tmp_str = tmp_str.replace("\t", " ");
hint_text += ' ' + tmp_str;
}
}
// Режем
hint_text = hint_text.replace(new RegExp(' {2,}'), ' ').replace(new RegExp(' +$'), '').substr(1);
if (hint_text.length > 140) {
hint_text = hint_text.substr(0, 140 - 3) + '...';
}
all_post_images.attr('data-fancybox-title', hint_text);
});
// Videos // Videos
if (options.option_fancybox_videos == true) { if (options.option_fancybox_videos == true) {
$('.postimg.youtube').addClass('fancybox-media').fancybox({ $('.postimg.youtube').addClass('fancybox-media').fancybox({
@ -107,25 +170,34 @@ $(document).ready(function() {
// NSFW Filtering // NSFW Filtering
if (options.option_nsfw == true) { if (options.option_nsfw == true) {
// Blurred posts $('.post-tag-nsfw,.post-tag-сиськи').find('a.postimg:not(.youtube)').attr('data-fancybox-group', 'hidden-images');
if (options.option_nsfw_blur == true) {
console.log('Bluring NSFW posts');
$('.post').each(function() { if (options.option_nsfw_hide_posts == true) {
$(this).find('a.tag').each(function() { if ($('#comments').length == 0) {
if ($(this).html().toLowerCase() == 'nsfw') { console.log('Hide NSFW posts in feed');
console.log('NSFW tag found!'); $('.post').addClass('hide-nsfw-posts');
}
} else {
// Blurred posts
if (options.option_nsfw_blur_posts_entire == true) {
console.log('Bluring NSFW posts');
$('.post').addClass('blur-nsfw-entire');
} else if (options.option_nsfw_blur_posts_images == true) {
console.log('Bluring images in NSFW posts');
$('.post').addClass('blur-nsfw-images');
}
}
$(this).wrapInner('<b></b>'); // Blurred comments
$(this).parent().siblings('.text').css('-webkit-filter', 'blur(30px)'); if ($('.post').hasClass('post-tag-nsfw') || $('.post').hasClass('post-tag-сиськи')) {
if (options.option_nsfw_blur_comments_entire == true) {
// Blurred comments console.log('Bluring comments');
if (options.option_nsfw_blur_comments == true) { $('#comments').addClass('blur-nsfw-entire');
$('#comments').css('-webkit-filter', 'blur(30px)'); } else if (options.option_nsfw_blur_comments_images == true) {
} // @hint Никита Ветров официально складывает с себя все претензии, если у кого-то от этого говна упадёт драйвер видео-карты
} console.log('Bluring images in comments');
}); $('#comments').addClass('blur-nsfw-images');
}); }
} }
} }
@ -134,14 +206,14 @@ $(document).ready(function() {
if (options.option_ctrl_enter == true) { if (options.option_ctrl_enter == true) {
// Reply // Reply
// Delegated event for all comments // Delegated event for all comments
$('.content-wrap #comments').on('keydown.point_plus', '.reply-form textarea', function(e) { $('.content-wrap #comments').on('keydown.point_plus', '.reply-form textarea', function (e) {
if (e.ctrlKey && (e.keyCode == 10 || e.keyCode == 13)) { if (e.ctrlKey && (e.keyCode == 10 || e.keyCode == 13)) {
e.preventDefault(); e.preventDefault();
$(this).parent('.reply-form').submit(); $(this).parent('.reply-form').submit();
} }
}); });
// New post // New post
$('#new-post-form #text-input,#new-post-form #tags-input').on('keydown.point_plus', function(e) { $('#new-post-form #text-input,#new-post-form #tags-input').on('keydown.point_plus', function (e) {
if (e.ctrlKey && (e.keyCode == 10 || e.keyCode == 13)) { if (e.ctrlKey && (e.keyCode == 10 || e.keyCode == 13)) {
e.preventDefault(); e.preventDefault();
$(this).parent('#new-post-form').submit(); $(this).parent('#new-post-form').submit();
@ -160,7 +232,7 @@ $(document).ready(function() {
// Image resizing // Image resizing
if (options.option_images_load_original == true) { if (options.option_images_load_original == true) {
// Setting new image source // Setting new image source
$('.postimg:not(.youtube) img').each(function() { $('.postimg:not(.youtube) img').each(function () {
console.log($(this).parent('.postimg').attr('href')); console.log($(this).parent('.postimg').attr('href'));
$(this).attr('src', $(this).parent('.postimg').attr('href')); $(this).attr('src', $(this).parent('.postimg').attr('href'));
}); });
@ -182,7 +254,7 @@ $(document).ready(function() {
// Send by CTRL+Enter // Send by CTRL+Enter
if (options.option_ctrl_enter == true) { if (options.option_ctrl_enter == true) {
// New post // New post
$('#new-post-form #text-input, .post-content #text-input').on('keydown.point_plus', function(e) { $('#new-post-form #text-input, .post-content #text-input').on('keydown.point_plus', function (e) {
if (e.ctrlKey && (e.keyCode == 10 || e.keyCode == 13)) { if (e.ctrlKey && (e.keyCode == 10 || e.keyCode == 13)) {
e.preventDefault(); e.preventDefault();
$(this).parents('#new-post-form,#post-edit-form').submit(); $(this).parents('#new-post-form,#post-edit-form').submit();
@ -192,7 +264,7 @@ $(document).ready(function() {
} }
// Google search // Google search
if (options.option_search_with_google == true) { if (options.option_search_with_google == true) {
$('#search-form input[type="text"]').attr('placeholder', 'Google').keydown(function(e) { $('#search-form input[type="text"]').attr('placeholder', 'Google').keydown(function (e) {
if (e.keyCode == 10 || e.keyCode == 13) { if (e.keyCode == 10 || e.keyCode == 13) {
e.preventDefault(); e.preventDefault();
document.location.href = '//www.google.ru/search?q=site%3Apoint.im+' + $(this).val(); document.location.href = '//www.google.ru/search?q=site%3Apoint.im+' + $(this).val();
@ -213,12 +285,12 @@ $(document).ready(function() {
console.debug('Comments view mode: %s', treeSwitch); console.debug('Comments view mode: %s', treeSwitch);
// Error handler // Error handler
ws.onerror = function(err) { ws.onerror = function (err) {
console.error('WebSocket error: %O', err); console.error('WebSocket error: %O', err);
}; };
// Message handler // Message handler
ws.onmessage = function(evt) { ws.onmessage = function (evt) {
try { try {
// ping :) // ping :)
if (evt.data == 'ping') { if (evt.data == 'ping') {
@ -265,7 +337,7 @@ $(document).ready(function() {
}); });
// Loading HTML template // Loading HTML template
$commentTemplate.load(chrome.extension.getURL('includes/comment.html'), function() { $commentTemplate.load(chrome.extension.getURL('includes/comment.html'), function () {
// Load complete // Load complete
console.info('comment.html loaded'); console.info('comment.html loaded');
@ -284,11 +356,11 @@ $(document).ready(function() {
console.info('Changing data in the comment element'); console.info('Changing data in the comment element');
// Date and time // Date and time
$commentTemplate.find('.info .created') $commentTemplate.find('.info .created')
.append($('<span>').html(((date.getDate().toString.length < 2) ? ('0' + date.getDate().toString()) : (date.getDate().toString())) + '&nbsp;' + months[date.getMonth()])) .append($('<span>').html(((date.getDate().toString.length < 2) ? ('0' + date.getDate().toString()) : (date.getDate().toString())) + '&nbsp;' + months[date.getMonth()]))
// Crutchy fix // Crutchy fix
.append($('<br>')) .append($('<br>'))
///Crutchy fix ///Crutchy fix
.append($('<span>').html(date.getHours() + ':' + ((date.getMinutes().toString().length < 2) ? ('0' + date.getMinutes().toString()) : (date.getMinutes().toString())))); .append($('<span>').html(date.getHours() + ':' + ((date.getMinutes().toString().length < 2) ? ('0' + date.getMinutes().toString()) : (date.getMinutes().toString()))));
// Comment text // Comment text
$commentTemplate.find('.text').append($('<p>').html(escapeHtml(wsMessage.text))); $commentTemplate.find('.text').append($('<p>').html(escapeHtml(wsMessage.text)));
// Author // Author
@ -297,8 +369,8 @@ $(document).ready(function() {
$commentTemplate.find('.info a').attr('href', userLink).children('img.avatar').attr('src', userAvatar + '/24'); $commentTemplate.find('.info a').attr('href', userLink).children('img.avatar').attr('src', userAvatar + '/24');
// Post and comment ID's link // Post and comment ID's link
$commentTemplate.find('.clearfix .post-id a').attr('href', commentLink).html('#' + wsMessage.post_id + '/' + wsMessage.comment_id) $commentTemplate.find('.clearfix .post-id a').attr('href', commentLink).html('#' + wsMessage.post_id + '/' + wsMessage.comment_id)
// Adding answer label // Adding answer label
.after((wsMessage.to_comment_id !== null) ? (' в ответ на <a href="#' + wsMessage.to_comment_id + '">/' + wsMessage.to_comment_id + '</a>') : ('')); .after((wsMessage.to_comment_id !== null) ? (' в ответ на <a href="#' + wsMessage.to_comment_id + '">/' + wsMessage.to_comment_id + '</a>') : (''));
// Setting action labels and other attributes // Setting action labels and other attributes
$commentTemplate.find('.action-labels .reply-label').attr('for', 'reply-' + wsMessage.post_id + '_' + wsMessage.comment_id); $commentTemplate.find('.action-labels .reply-label').attr('for', 'reply-' + wsMessage.post_id + '_' + wsMessage.comment_id);
$commentTemplate.find('.action-labels .more-label').attr('for', 'action-' + wsMessage.post_id + '_' + wsMessage.comment_id); $commentTemplate.find('.action-labels .more-label').attr('for', 'action-' + wsMessage.post_id + '_' + wsMessage.comment_id);
@ -368,31 +440,31 @@ $(document).ready(function() {
break; break;
// Posts // Posts
case 'post': case 'post':
console.group('ws-post #%s', wsMessage.post_id); console.group('ws-post #%s', wsMessage.post_id);
console.debug(wsMessage); console.debug(wsMessage);
console.groupEnd(); console.groupEnd();
break; break;
// Recommendation // Recommendation
case 'ok': case 'ok':
console.group('ws-recommendation #%s/%s', wsMessage.post_id, wsMessage.comment_id); console.group('ws-recommendation #%s/%s', wsMessage.post_id, wsMessage.comment_id);
console.debug(wsMessage); console.debug(wsMessage);
console.groupEnd(); console.groupEnd();
break; break;
default: default:
console.group('ws-other'); console.group('ws-other');
console.log(wsMessage); console.log(wsMessage);
console.groupEnd(); console.groupEnd();
break; break;
} }
} }
@ -420,15 +492,19 @@ $(document).ready(function() {
} }
// Hightlight post with new comments // Hightlight post with new comments
if (options.option_other_hightlight_post_comments == true){ if (options.option_other_hightlight_post_comments == true) {
mark_unread_post(); mark_unread_post();
} }
// Show recommendation count and unique commentators count // Show recommendation count and unique commentators count
if (options.option_other_show_recommendation_count == true){ if (options.option_other_show_recommendation_count == true) {
set_posts_count_label(); set_posts_count_label();
} }
// `Space` key scroll handler
if (options.option_other_scroll_space_key == true){
set_space_key_skip_handler();
}
$('.point-plus-debug').fadeOut(500);
}); });
// Showing page action // Showing page action
@ -437,12 +513,12 @@ $(document).ready(function() {
function escapeHtml(text) { function escapeHtml(text) {
return text return text
.replace(/&/g, "&amp;") .replace(/&/g, "&amp;")
.replace(/</g, "&lt;") .replace(/</g, "&lt;")
//.replace(/>/g, "&gt;") //.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;") .replace(/"/g, "&quot;")
.replace(/'/g, "&#039;") .replace(/'/g, "&#039;")
.replace(/\n/g, "<br>"); .replace(/\n/g, "<br>");
} }
// Monts for Date.getMonth() // Monts for Date.getMonth()
@ -452,7 +528,6 @@ var months = [
]; ];
/* Nokita's functions */
// Картинки с бурятников // Картинки с бурятников
var booru_picture_count = 0; var booru_picture_count = 0;
function load_all_booru_images() { function load_all_booru_images() {
@ -541,7 +616,7 @@ function create_image(domain, id, additional) {
return a; return a;
} }
/* point */ // Помечаем непрочитанные посты более видимо чем каким-то баджем
// Эта часть написана @RainbowSpike // Эта часть написана @RainbowSpike
function mark_unread_post() { function mark_unread_post() {
var divs = $(".post"); // массив постов var divs = $(".post"); // массив постов
@ -580,9 +655,44 @@ function parse_webm() {
}); });
} }
function parse_all_videos() {
$('a').each(function (num, obj) {
if ($(obj).hasClass('booru_pic')) {
return;
}
var href = obj.href;
var n = null;
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({
'display': 'block',
'max-width': '95%'
}).addClass('parsed-webm-link');
obj.parentElement.insertBefore(player, obj);
}
});
}
function video_extension_to_mime(extension) {
switch(extension){
case 'webm':return 'video/webm; codecs="vp8, vorbis';
case 'avi' :return 'video/avi;';
case 'mp4' :return 'video/mp4;';
case 'mpg' :return 'video/mp4;';
case 'mpeg':return 'video/mp4;';
}
}
// Плашки у постов // Плашки у постов
function set_posts_count_label() { function set_posts_count_label() {
var ids = []; var ids = [];
$('.post .post-id a .cn').addClass('changed_background');
$('div.post').each(function (num, obj) { $('div.post').each(function (num, obj) {
var t = $(obj).attr('data-comment-id'); var t = $(obj).attr('data-comment-id');
if (typeof(t) !== 'undefined') { if (typeof(t) !== 'undefined') {
@ -606,12 +716,14 @@ function set_posts_count_label() {
} }
var e1 = document.createElement('span'); var e1 = document.createElement('span');
if (typeof(answer.list[id])=='undefined'){return;} 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);
var e2 = document.createElement('span'); var e2 = document.createElement('span');
$(e2).addClass('recomendation_count').html('~' + answer.list[id].count_recommendation).attr('title', 'Количество рекомендаций. Работает криво, спасибо @arts\'у за это'); $(e2).addClass('recommendation_count').html('~' + answer.list[id].count_recommendation).attr('title', 'Количество рекомендаций. Работает криво, спасибо @arts\'у за это');
postid.appendChild(e2); postid.appendChild(e2);
}); });
} }
@ -620,11 +732,11 @@ function set_posts_count_label() {
} }
function parse_pleercom_links(){ function parse_pleercom_links() {
chrome.storage.sync.get(ppOptions, function(options) { chrome.storage.sync.get(ppOptions, function (options) {
if (options.option_embedding_pleercom_nokita_server){ if (options.option_embedding_pleercom_nokita_server) {
parse_pleercom_links_nokita(); parse_pleercom_links_nokita();
}else{ } else {
parse_pleercom_links_ajax(); parse_pleercom_links_ajax();
} }
}); });
@ -643,8 +755,8 @@ function parse_pleercom_links_nokita() {
'preload': 'none' 'preload': 'none'
}); });
var player_div=document.createElement('div'); var player_div = document.createElement('div');
$(player_div).addClass('embeded_audio').addClass('embeded_audio_'+n[1]); $(player_div).addClass('embeded_audio').addClass('embeded_audio_' + n[1]);
player_div.appendChild(player); player_div.appendChild(player);
obj.parentElement.insertBefore(player_div, obj); obj.parentElement.insertBefore(player_div, obj);
@ -652,28 +764,28 @@ function parse_pleercom_links_nokita() {
}); });
} }
function parse_pleercom_links_ajax(){ function parse_pleercom_links_ajax() {
$('a').each(function (num, obj) { $('a').each(function (num, obj) {
var href = obj.href; var href = obj.href;
var n = null; var n = null;
if (n = 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_div=document.createElement('div'); var player_div = document.createElement('div');
$(player_div).addClass('embeded_audio').addClass('embeded_audio_'+n[1]); $(player_div).addClass('embeded_audio').addClass('embeded_audio_' + n[1]);
obj.parentElement.insertBefore(player_div, obj); obj.parentElement.insertBefore(player_div, obj);
create_pleercom_ajax(n[1]); create_pleercom_ajax(n[1]);
} }
}); });
} }
function create_pleercom_ajax(id){ function create_pleercom_ajax(id) {
$ajax({ $ajax({
'url':'https://pleer.com/site_api/files/get_url', 'url': 'https://pleer.com/site_api/files/get_url',
'type':'post', 'type': 'post',
'postdata':'action=download&id='+id, 'postdata': 'action=download&id=' + id,
'dont_set_content_type':true, 'dont_set_content_type': true,
'pleer_id':id, 'pleer_id': id,
'headers':[['Accept','*'],['Content-Type','application/x-www-form-urlencoded; charset=UTF-8']], 'headers': [['Accept', '*'], ['Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8']],
'success': function (a) { 'success': function (a) {
var answer = JSON.parse(a); var answer = JSON.parse(a);
var player = document.createElement('audio'); var player = document.createElement('audio');
@ -683,13 +795,96 @@ function create_pleercom_ajax(id){
'controls': 'controls', 'controls': 'controls',
'preload': 'auto' 'preload': 'auto'
}); });
$('.embeded_audio_'+this.settings.pleer_id)[0].appendChild(player); $('.embeded_audio_' + this.settings.pleer_id)[0].appendChild(player);
}, },
'error':function(){ 'error': function () {
console.log('Can not get url'); console.log('Can not get url');
setTimeout(new Function('create_pleercom_ajax("'+this.settings.pleer_id+'");'), 1000); setTimeout(new Function('create_pleercom_ajax("' + this.settings.pleer_id + '");'), 1000);
} }
}); });
} }
// Проставляем теги у постов
function create_tag_system() {
$('.post').each(function () {
var tags = $(this).find('div.tags a.tag');
for (var i = 0; i < tags.length; i++) {
var tag_name = $(tags[i]).html().toLowerCase();
$(this).addClass('post-tag-' + tag_name);
}
});
}
// Скролл по пробелу
function set_space_key_skip_handler(){
if ($('#comments').length>0){
return;
}
// @todo Свериться с Best-practice биндинга функций. Мб там on или bind
$(document.body).keydown(function(e){
// @todo Я хотел по отпусканию кнопки, но там уже скролл срабатывает
// проверяем фокус
if ($(':focus').length>0) {
return;
}
var k=event.keyCode;
if (k==32){
space_key_event();
return false;
}
});
}
// Проставляем теги у постов
function create_tag_system() {
$('.post').each(function () {
var tags = $(this).find('div.tags a.tag');
for (var i = 0; i < tags.length; i++) {
var tag_name = $(tags[i]).html().toLowerCase();
$(this).addClass('post-tag-' + tag_name);
}
});
}
// Скролл по пробелу
function set_space_key_skip_handler() {
if ($('#comments').length > 0) {
return;
}
// @todo Свериться с Best-practice биндинга функций. Мб там on или bind
$(document.body).keydown(function (e) {
// @todo Я хотел по отпусканию кнопки, но там уже скролл срабатывает
// проверяем фокус
if ($(':focus').length > 0) {
return;
}
var k = event.keyCode;
if (k == 32) {
space_key_event();
return false;
}
});
}
function space_key_event() {
var scroll_current = $('body').scrollTop();
var scroll_step_size = 0;
var scroll_real = Math.max(scroll_current - scroll_step_size, 0);
var posts = $('.post');
for (var i = 0; i < posts.length; i++) {
var this_top_px = $(posts[i]).offset().top;
if (this_top_px > scroll_real) {
$('body').animate({
'scrollTop': this_top_px
}, 200);
return;
}
}
}

View file

@ -1,7 +1,7 @@
{ {
"manifest_version": 2, "manifest_version": 2,
"name": "Point+", "name": "Point+",
"version": "1.13.0", "version": "1.14.2",
"default_locale": "ru", "default_locale": "ru",
"author": "__MSG_ext_author__", "author": "__MSG_ext_author__",
"homepage_url": "https://bitbucket.org/skobkin/chrome_point_plus", "homepage_url": "https://bitbucket.org/skobkin/chrome_point_plus",

View file

@ -51,6 +51,10 @@
<div class="option"> <div class="option">
<input type="checkbox" id="option-videos-parse-webm"><label for="option-videos-parse-webm" data-i18n="option_videos_parse_webm"></label> <input type="checkbox" id="option-videos-parse-webm"><label for="option-videos-parse-webm" data-i18n="option_videos_parse_webm"></label>
<div class="option">
<input type="checkbox" id="option-videos-parse-all-videos"><label for="option-videos-parse-all-videos" data-i18n="option_videos_parse_all_videos"></label>
</div>
</div> </div>
<div class="option"> <div class="option">
@ -74,10 +78,22 @@
<input type="checkbox" id="option-nsfw"><label for="option-nsfw" data-i18n="option_nsfw"></label> <input type="checkbox" id="option-nsfw"><label for="option-nsfw" data-i18n="option_nsfw"></label>
<div class="option"> <div class="option">
<input type="checkbox" id="option-nsfw-blur"><label for="option-nsfw-blur" data-i18n="option_nsfw_blur"></label> <input type="checkbox" id="option-nsfw-hide-posts"><label for="option-nsfw-hide-posts" data-i18n="option_nsfw_hide_posts"></label>
</div>
<div class="option">
<input type="checkbox" id="option-nsfw-blur-posts-images"><label for="option-nsfw-blur-posts-images" data-i18n="option_nsfw_blur_posts_images"></label>
<div class="option"> <div class="option">
<input type="checkbox" id="option-nsfw-blur-comments"><label for="option-nsfw-blur-comments" data-i18n="option_nsfw_blur_comments"></label> <input type="checkbox" id="option-nsfw-blur-posts-entire"><label for="option-nsfw-blur-posts-entire" data-i18n="option_nsfw_blur_posts_entire"></label>
</div>
</div>
<div class="option">
<input type="checkbox" id="option-nsfw-blur-comments-images"><label for="option-nsfw-blur-comments-images" data-i18n="option_nsfw_blur_comments_images"></label>
<div class="option">
<input type="checkbox" id="option-nsfw-blur-comments-entire"><label for="option-nsfw-blur-comments-entire" data-i18n="option_nsfw_blur_comments_entire"></label>
</div> </div>
</div> </div>
</div> </div>
@ -122,6 +138,9 @@
<input type="checkbox" id="option-other-show-recommendation-count"><label for="option-other-show-recommendation-count" data-i18n="option_other_show_recommendation_count"></label> <input type="checkbox" id="option-other-show-recommendation-count"><label for="option-other-show-recommendation-count" data-i18n="option_other_show_recommendation_count"></label>
</div> </div>
<div class="option">
<input type="checkbox" id="option-other-scroll-space-key"><label for="option-other-scroll-space-key" data-i18n="option_other_scroll_space_key"></label>
</div>
</div> </div>
<div class="tab-content" id="websocket"> <div class="tab-content" id="websocket">