- @ 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) { chrome.extension.onMessage.addListener(function(message, sender) {
if (message && message.type === 'showPageAction') { console.log('Received message: %O', message);
var tab = sender.tab;
chrome.pageAction.show(tab.id);
}
if (message && message.type === 'showNotification') { if (message) {
console.log(chrome.notifications.create( switch (message.type) {
message.notificationId, { case 'showPageAction':
type: 'basic', var tab = sender.tab;
iconUrl: message.avatarUrl, chrome.pageAction.show(tab.id);
title: message.title, break;
message: message.text,
priority: 0 case 'showNotification':
}, console.log(chrome.notifications.create(
function() { /* Error checking goes here */} 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 // Feeds
'option_ws_feeds', 'option_ws_feeds_subscriptions', 'option_ws_feeds_blogs', 'option_ws_feeds', 'option_ws_feeds_subscriptions', 'option_ws_feeds_blogs',
// Font size // 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. // Saves options to localStorage.
@ -61,6 +63,8 @@ function pp_save_options() {
var option_enlarge_font = document.getElementById('option-enlarge-font'); var option_enlarge_font = document.getElementById('option-enlarge-font');
// Size ratio // Size ratio
var option_enlarge_font_size = document.querySelector('input[name="pp-font-size"]:checked'); 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 // Saving parameters
chrome.storage.sync.set({ chrome.storage.sync.set({
@ -81,7 +85,8 @@ function pp_save_options() {
'option_ws_feeds_subscriptions': option_ws_feeds_subscriptions.checked, 'option_ws_feeds_subscriptions': option_ws_feeds_subscriptions.checked,
'option_ws_feeds_blogs': option_ws_feeds_blogs.checked, 'option_ws_feeds_blogs': option_ws_feeds_blogs.checked,
'option_enlarge_font': option_enlarge_font.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() { }, function() {
// Update status to let user know options were saved. // Update status to let user know options were saved.
var status = document.getElementById('status'); var status = document.getElementById('status');
@ -174,6 +179,10 @@ function pp_restore_options() {
if (options.option_enlarge_font_size !== undefined) { if (options.option_enlarge_font_size !== undefined) {
document.getElementById('option-enlarge-font-' + options.option_enlarge_font_size).checked = true; 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 // Showing version
document.getElementById('pp-version').innerHTML = 'Point+ ' + getVersion() + ' by <a href="http://skobkin-ru.point.im/" target="_blank">@skobkin-ru</a>'; 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)) { 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');
} }
// @ before username
if (options.option_at_before_username == true) {
chrome.extension.sendMessage({
type: 'injectCSSFile',
file: 'css/modules/at_before_username.css'
});
}
}); });
// Showing page action // 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> <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> </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>
<div class="tab-content" id="websocket"> <div class="tab-content" id="websocket">