- NSFW content filtration (#32)

- Options auto save without closing (#29)
This commit is contained in:
Alexey Skobkin 2014-11-20 20:47:47 +04:00
parent 33db041b92
commit bedb73e754
7 changed files with 82 additions and 14 deletions

View file

@ -10,8 +10,8 @@
}, },
"options_buttons_save": { "options_text_saved": {
"message": "Save" "message": "Reload page to apply changes."
}, },
@ -68,6 +68,15 @@
"option_embedding_pleercom_nokita_server": { "option_embedding_pleercom_nokita_server": {
"message": "Use Nokita's server instead of AJAX to get mp3 link" "message": "Use Nokita's server instead of AJAX to get mp3 link"
}, },
"option_nsfw": {
"message": "NSFW content filtering"
},
"option_nsfw_blur": {
"message": "Blurring"
},
"option_nsfw_blur_comments": {
"message": "Blur comments too"
},
"option_ctrl_enter": { "option_ctrl_enter": {
"message": "Send post and comments by CTRL+Enter (deprecated)" "message": "Send post and comments by CTRL+Enter (deprecated)"
}, },

View file

@ -10,8 +10,8 @@
}, },
"options_buttons_save": { "options_text_saved": {
"message": "Сохранить" "message": "Для применения изменений перезагрузите страницу."
}, },
@ -68,6 +68,15 @@
"option_embedding_pleercom_nokita_server": { "option_embedding_pleercom_nokita_server": {
"message": "Использовать сервер @NokitaKaze вместо AJAX-запроса для получения mp3" "message": "Использовать сервер @NokitaKaze вместо AJAX-запроса для получения mp3"
}, },
"option_nsfw": {
"message": "Фильтрация NSFW-контента"
},
"option_nsfw_blur": {
"message": "Размытие небезопасных постов"
},
"option_nsfw_blur_comments": {
"message": "Размытие комментариев"
},
"option_ctrl_enter": { "option_ctrl_enter": {
"message": "Отправлять текст по CTRL+Enter (устарело)" "message": "Отправлять текст по CTRL+Enter (устарело)"
}, },

View file

@ -151,6 +151,10 @@ div#markItUpText-input {
float: right; float: right;
} }
.pp-options #status {
display: block;
}
.pp-options #pp-version { .pp-options #pp-version {
margin-top: 6px; margin-top: 6px;
text-align: right; text-align: right;

View file

@ -23,6 +23,12 @@ var ppOptions = [
// Pleer.com // Pleer.com
'option_embedding_pleercom', 'option_embedding_pleercom',
'option_embedding_pleercom_nokita_server', 'option_embedding_pleercom_nokita_server',
// NSFW filtering
'option_nsfw',
// Blured pictures
'option_nsfw_blur',
// Blur comments too
'option_nsfw_blur_comments',
// CTRL+Enter // CTRL+Enter
'option_ctrl_enter', 'option_ctrl_enter',
// Fluid layout // Fluid layout
@ -65,6 +71,9 @@ function pp_save_options() {
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_blur = $('#option-nsfw-blur').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');
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');
@ -83,10 +92,7 @@ function pp_save_options() {
// Saving parameters // Saving parameters
chrome.storage.sync.set(ppOptions, function() { chrome.storage.sync.set(ppOptions, function() {
// Update status to let user know options were saved. // Update status to let user know options were saved.
$('#status').html('Options Saved.'); $('#status').html(chrome.i18n.getMessage('options_text_saved'));
setTimeout(function() {
window.close();
}, 1500);
}); });
} }
@ -127,6 +133,14 @@ if (point_plus_options_save_button !== null) {
point_plus_options_save_button.addEventListener('click', pp_save_options); point_plus_options_save_button.addEventListener('click', pp_save_options);
} }
// Binding event listeners
$(function() {
// Delegating events
$('#tabs-content').on('click', 'input', function() {
pp_save_options();
});
});
// Getting version from manifest.json // Getting version from manifest.json
function getVersion() { function getVersion() {
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();

View file

@ -105,6 +105,30 @@ $(document).ready(function() {
} }
} }
// NSFW Filtering
if (options.option_nsfw == true) {
// Blurred posts
if (options.option_nsfw_blur == true) {
console.log('Bluring NSFW posts');
$('.post').each(function() {
$(this).find('a.tag').each(function() {
if ($(this).html().toLowerCase() == 'nsfw') {
console.log('NSFW tag found!');
$(this).wrapInner('<b></b>');
$(this).parent().siblings('.text').css('-webkit-filter', 'blur(30px)');
// Blurred comments
if (options.option_nsfw_blur_comments == true) {
$('#comments').css('-webkit-filter', 'blur(30px)');
}
}
});
});
}
}
// Hotkeys // Hotkeys
// Send by CTRL+Enter // Send by CTRL+Enter
if (options.option_ctrl_enter == true) { if (options.option_ctrl_enter == true) {

View file

@ -1,7 +1,7 @@
{ {
"manifest_version": 2, "manifest_version": 2,
"name": "Point+", "name": "Point+",
"version": "1.12.0", "version": "1.13.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

@ -69,6 +69,18 @@
</div> </div>
</div> </div>
</div> </div>
<div class="option">
<input type="checkbox" id="option-nsfw"><label for="option-nsfw" data-i18n="option_nsfw"></label>
<div class="option">
<input type="checkbox" id="option-nsfw-blur"><label for="option-nsfw-blur" data-i18n="option_nsfw_blur"></label>
<div class="option">
<input type="checkbox" id="option-nsfw-blur-comments"><label for="option-nsfw-blur-comments" data-i18n="option_nsfw_blur_comments"></label>
</div>
</div>
</div>
</div> </div>
<div class="tab-content" id="other"> <div class="tab-content" id="other">
@ -149,11 +161,7 @@
<div id="panel"> <div id="panel">
<div id="status"></div> <div class="left" id="status"></div>
<div class="left">
<button id="save" class="button" data-i18n="options_buttons_save"></button>
</div>
<div class="right"> <div class="right">
<div id="pp-version"></div> <div id="pp-version"></div>