* Другой блюр, теперь нормальный. Блюрить текст — максимум пидорство

+ По ховеру на заблюреным изображением — появляется нормальное изображение
+ Скроллинг между постов по пробелу
+ Превращаем в video все ссылки на видео и молимся
* ФОРМАТИРУЕМ КОД, БЛЕАТЬ
This commit is contained in:
Nokita Kaze 2014-11-21 18:49:12 +03:00
parent ff51da8c3a
commit 16b86255ec
7 changed files with 256 additions and 110 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,6 +74,9 @@
"option_nsfw": { "option_nsfw": {
"message": "NSFW content filtering" "message": "NSFW content filtering"
}, },
"option_nsfw_hide_posts":{
"message": "Hide entire posts with `nsfw` tag"
},
"option_nsfw_blur": { "option_nsfw_blur": {
"message": "Blurring" "message": "Blurring"
}, },
@ -122,7 +128,10 @@
"option_other_show_recommendation_count": { "option_other_show_recommendation_count": {
"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,6 +74,9 @@
"option_nsfw": { "option_nsfw": {
"message": "Фильтрация NSFW-контента" "message": "Фильтрация NSFW-контента"
}, },
"option_nsfw_hide_posts":{
"message": "Скрывать NSFW-посты полностью"
},
"option_nsfw_blur": { "option_nsfw_blur": {
"message": "Размытие небезопасных постов" "message": "Размытие небезопасных постов"
}, },
@ -122,8 +128,12 @@
"option_other_show_recommendation_count": { "option_other_show_recommendation_count": {
"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

@ -184,3 +184,19 @@ div#markItUpText-input {
margin-left: 0.2em; margin-left: 0.2em;
background: #f2eceb; background: #f2eceb;
} }
/* NSFW-content */
.post-tag-nsfw.hide-nsfw a.postimg img,
#comments.hide-nsfw a.postimg img{
margin-top: 5px;
-webkit-filter: blur(30px);
}
.post-tag-nsfw.hide-nsfw a.postimg:hover img,
#comments.hide-nsfw a.postimg:hover img{
-webkit-filter: none;
}
.post-tag-nsfw.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,6 +26,7 @@ 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',
// Blur comments too // Blur comments too
@ -51,6 +53,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,11 +71,13 @@ 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_hide_posts = $('#option-nsfw-hide-posts').prop('checked');
ppOptions.option_nsfw_blur = $('#option-nsfw-blur').prop('checked'); ppOptions.option_nsfw_blur = $('#option-nsfw-blur').prop('checked');
ppOptions.option_nsfw_blur_comments = $('#option-nsfw-blur-comments').prop('checked'); ppOptions.option_nsfw_blur_comments = $('#option-nsfw-blur-comments').prop('checked');
ppOptions.option_visual_editor_post = $('#option-visual-editor-post').prop('checked'); ppOptions.option_visual_editor_post = $('#option-visual-editor-post').prop('checked');
@ -88,6 +94,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,17 @@
$(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());
// 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 +20,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,7 +69,7 @@ $(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('rel', 'one_flow_gallery');
@ -71,7 +78,7 @@ $(document).ready(function() {
// 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('rel', 'post' + idxPost);
@ -104,44 +111,42 @@ $(document).ready(function() {
}); });
} }
} }
// NSFW Filtering // NSFW Filtering
if (options.option_nsfw == true) { if (options.option_nsfw == true) {
// Blurred posts if (options.option_nsfw_hide_posts == true) {
if (options.option_nsfw_blur == true) { if ($('#comments').length==0) {
console.log('Bluring NSFW posts'); // @hint Поведение "галка нажата, а внутри постов НЕ блюрится, даже если нажаты все три галки" - не баг
console.log('Hide NSFW posts');
$('.post').each(function() { $('.post').addClass('hide-nsfw-posts');
$(this).find('a.tag').each(function() { }
if ($(this).html().toLowerCase() == 'nsfw') { } else {
console.log('NSFW tag found!'); // Blurred posts
if (options.option_nsfw_blur == true) {
$(this).wrapInner('<b></b>'); console.log('Bluring NSFW posts');
$(this).parent().siblings('.text').css('-webkit-filter', 'blur(30px)'); $('.post').addClass('hide-nsfw');
// Blurred comments // Blurred comments
if (options.option_nsfw_blur_comments == true) { if (options.option_nsfw_blur_comments == true) {
$('#comments').css('-webkit-filter', 'blur(30px)'); $('#comments').addClass('hide-nsfw');
} }
} }
});
});
} }
} }
// Hotkeys // Hotkeys
// Send by CTRL+Enter // Send by CTRL+Enter
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 +165,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 +187,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 +197,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();
@ -204,21 +209,21 @@ $(document).ready(function() {
// SSL or plain // SSL or plain
ws = new WebSocket(((location.protocol == 'https:') ? 'wss' : 'ws') + '://point.im/ws'); ws = new WebSocket(((location.protocol == 'https:') ? 'wss' : 'ws') + '://point.im/ws');
console.log('WebSocket created: %O', ws); console.log('WebSocket created: %O', ws);
// Detecting post id if presented // Detecting post id if presented
var postId = $('#top-post').attr('data-id'); var postId = $('#top-post').attr('data-id');
console.debug('Current post id detected as #%s', postId); console.debug('Current post id detected as #%s', postId);
// Detecting view mode // Detecting view mode
treeSwitch = $('#tree-switch a.active').attr('href'); treeSwitch = $('#tree-switch a.active').attr('href');
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') {
@ -246,14 +251,14 @@ $(document).ready(function() {
console.groupEnd(); console.groupEnd();
break; break;
} }
// Check we are in specified post // Check we are in specified post
if (wsMessage.post_id != postId) { if (wsMessage.post_id != postId) {
console.log('The comment is for #%s but current page is for #%s', wsMessage.post_id, postId); console.log('The comment is for #%s but current page is for #%s', wsMessage.post_id, postId);
console.groupEnd(); console.groupEnd();
break; break;
} }
var $anchor = $('<a>').attr('name', wsMessage.comment_id); var $anchor = $('<a>').attr('name', wsMessage.comment_id);
// Initializing comment element // Initializing comment element
@ -265,7 +270,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 +289,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 +302,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);
@ -344,13 +349,13 @@ $(document).ready(function() {
// Adding anchor // Adding anchor
$commentTemplate.before($anchor); $commentTemplate.before($anchor);
// Fading out highlight if needed // Fading out highlight if needed
if (options.option_ws_comments_color_fadeout == true) { if (options.option_ws_comments_color_fadeout == true) {
console.log('Fading out the highlight'); console.log('Fading out the highlight');
$commentTemplate.children('.pp-highlight').fadeOut(20000); $commentTemplate.children('.pp-highlight').fadeOut(20000);
} }
// Desktop notifications // Desktop notifications
if (options.option_ws_comments_notifications == true) { if (options.option_ws_comments_notifications == true) {
console.log('Showing desktop notification'); console.log('Showing desktop notification');
@ -362,38 +367,38 @@ $(document).ready(function() {
text: wsMessage.text text: wsMessage.text
}); });
} }
console.groupEnd(); console.groupEnd();
}); });
break;
// Posts
case 'post':
console.group('ws-post #%s', wsMessage.post_id);
console.debug(wsMessage);
console.groupEnd();
break;
// Recommendation
case 'ok':
console.group('ws-recommendation #%s/%s', wsMessage.post_id, wsMessage.comment_id);
console.debug(wsMessage);
console.groupEnd();
break;
default:
console.group('ws-other');
console.log(wsMessage);
console.groupEnd();
break; break;
// Posts
case 'post':
console.group('ws-post #%s', wsMessage.post_id);
console.debug(wsMessage);
console.groupEnd();
break;
// Recommendation
case 'ok':
console.group('ws-recommendation #%s/%s', wsMessage.post_id, wsMessage.comment_id);
console.debug(wsMessage);
console.groupEnd();
break;
default:
console.group('ws-other');
console.log(wsMessage);
console.groupEnd();
break;
} }
} }
@ -406,7 +411,7 @@ $(document).ready(function() {
} }
; ;
}; };
} }
// Font size // Font size
if ((options.option_enlarge_font == true) && (options.option_enlarge_font_size !== undefined)) { if ((options.option_enlarge_font == true) && (options.option_enlarge_font_size !== undefined)) {
$('body').css('font-size', (options.option_enlarge_font_size / 100) + 'em'); $('body').css('font-size', (options.option_enlarge_font_size / 100) + 'em');
@ -420,14 +425,17 @@ $(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();
} }
if (options.option_other_scroll_space_key == true){
set_space_key_skip_handler();
}
}); });
@ -437,12 +445,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()
@ -580,6 +588,38 @@ 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)(\\?.+)?$', '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;';// @hint Хотя сомнительно
case 'mp4' :return 'video/mp4;';
}
}
// Плашки у постов // Плашки у постов
function set_posts_count_label() { function set_posts_count_label() {
var ids = []; var ids = [];
@ -606,7 +646,9 @@ 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);
@ -620,11 +662,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 +685,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 +694,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 +725,63 @@ 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 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.0",
"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">
@ -72,7 +76,11 @@
<div class="option"> <div class="option">
<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">
<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"> <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-blur"><label for="option-nsfw-blur" data-i18n="option_nsfw_blur"></label>
@ -122,6 +130,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">