- @ before username

- Background message listener rewrited: 'injectCSSFile' and 'injectCSSCode' implemented
- Removed sourceMappingURL from jQuery
This commit is contained in:
Alexey Skobkin 2014-04-22 00:42:53 +04:00
parent 27bca63a00
commit fa68e41e04
6 changed files with 75 additions and 21 deletions

View File

@ -0,0 +1,8 @@
/* @ before username */
#main #content a.user:before {
content: "@";
}
/* Fix for recommendations in the feed */
#main #content .rec .user:before {
margin-right: -4px;
}

View File

@ -1,19 +1,46 @@
// Message listener
chrome.extension.onMessage.addListener(function(message, sender) {
if (message && message.type === 'showPageAction') {
var tab = sender.tab;
chrome.pageAction.show(tab.id);
}
console.log('Received message: %O', message);
if (message && message.type === 'showNotification') {
console.log(chrome.notifications.create(
message.notificationId, {
type: 'basic',
iconUrl: message.avatarUrl,
title: message.title,
message: message.text,
priority: 0
},
function() { /* Error checking goes here */}
));
}
if (message) {
switch (message.type) {
case 'showPageAction':
var tab = sender.tab;
chrome.pageAction.show(tab.id);
break;
case 'showNotification':
console.log(chrome.notifications.create(
message.notificationId, {
type: 'basic',
iconUrl: message.avatarUrl,
title: message.title,
message: message.text,
priority: 0
},
function() { /* Error checking goes here */}
));
break;
case 'injectJS':
break;
case 'injectCSSFile':
console.log('Injecting CSS: %s', message.file);
chrome.tabs.insertCSS(null, {
file: message.file
});
break;
case 'injectCSSCode':
if (message.code !== undefined) {
chrome.tabs.insertCSS(null, {
code: message.code
});
}
break;
}
}
});

File diff suppressed because one or more lines are too long

View File

@ -18,7 +18,9 @@ var ppOptions = [
// Feeds
'option_ws_feeds', 'option_ws_feeds_subscriptions', 'option_ws_feeds_blogs',
// Font size
'option_enlarge_font', 'option_enlarge_font_size'
'option_enlarge_font', 'option_enlarge_font_size',
// @ before username
'option_at_before_username'
];
// Saves options to localStorage.
@ -61,6 +63,8 @@ function pp_save_options() {
var option_enlarge_font = document.getElementById('option-enlarge-font');
// Size ratio
var option_enlarge_font_size = document.querySelector('input[name="pp-font-size"]:checked');
// @ before username
var option_at_before_username = document.getElementById('option-at-before-username');
// Saving parameters
chrome.storage.sync.set({
@ -81,7 +85,8 @@ function pp_save_options() {
'option_ws_feeds_subscriptions': option_ws_feeds_subscriptions.checked,
'option_ws_feeds_blogs': option_ws_feeds_blogs.checked,
'option_enlarge_font': option_enlarge_font.checked,
'option_enlarge_font_size': option_enlarge_font_size.value
'option_enlarge_font_size': option_enlarge_font_size.value,
'option_at_before_username': option_at_before_username.checked
}, function() {
// Update status to let user know options were saved.
var status = document.getElementById('status');
@ -174,6 +179,10 @@ function pp_restore_options() {
if (options.option_enlarge_font_size !== undefined) {
document.getElementById('option-enlarge-font-' + options.option_enlarge_font_size).checked = true;
}
// @ before username
if (options.option_at_before_username == true) {
document.getElementById('option-at-before-username').checked = true;
}
// Showing version
document.getElementById('pp-version').innerHTML = 'Point+ ' + getVersion() + ' by <a href="http://skobkin-ru.point.im/" target="_blank">@skobkin-ru</a>';

View File

@ -324,6 +324,14 @@ $(document).ready(function() {
if ((options.option_enlarge_font == true) && (options.option_enlarge_font_size !== undefined)) {
$('body').css('font-size', (options.option_enlarge_font_size / 100) + 'em');
}
// @ before username
if (options.option_at_before_username == true) {
chrome.extension.sendMessage({
type: 'injectCSSFile',
file: 'css/modules/at_before_username.css'
});
}
});
// Showing page action

View File

@ -77,6 +77,10 @@
<input name="pp-font-size" id="option-enlarge-font-110" type="radio" value="110"><label for="option-enlarge-font-110">1.1em</label>
</div>
</div>
<div class="option">
<input type="checkbox" id="option-at-before-username"><label for="option-at-before-username">&#64; before username</label>
</div>
</div>
<div class="tab-content" id="websocket">