Merged in fix_injection (pull request #24) Dynamic JS/CSS loading and some external lib fixes.

This commit is contained in:
Alexey Skobkin 2015-01-07 19:47:17 +03:00
commit e894e2756b
6 changed files with 311 additions and 280 deletions

View File

@ -0,0 +1,27 @@
/*
Created on : Jan 7, 2015, 8:58:42 AM
Author : skobkin
*/
/* Fancybox fix */
#fancybox-loading, .fancybox-close, .fancybox-prev span, .fancybox-next span {
background-image: url('chrome-extension://__MSG_@@extension_id__/vendor/fancybox/source/fancybox_sprite.png');
}
#fancybox-loading div {
background-image: url('chrome-extension://__MSG_@@extension_id__/vendor/fancybox/source/fancybox_loading.gif');
}
.fancybox-overlay {
background-image: url('chrome-extension://__MSG_@@extension_id__/vendor/fancybox/source/fancybox_overlay.png');
}
@media only screen and (min-device-pixel-ratio: 1.5) {
#fancybox-loading, .fancybox-close, .fancybox-prev span, .fancybox-next span {
background-image: url('chrome-extension://__MSG_@@extension_id__/vendor/fancybox/source/fancybox_sprite@2x.png');
}
#fancybox-loading div {
background-image: url('chrome-extension://__MSG_@@extension_id__/vendor/fancybox/source/fancybox_loading@2x.gif');
}
}

View File

@ -1,147 +1,36 @@
/* -------------------------------------------------------------------
// markItUp! Universal MarkUp Engine, JQuery plugin
// By Jay Salvat - http://markitup.jaysalvat.com/
// ------------------------------------------------------------------*/
.markItUp * {
margin:0px; padding:0px;
outline:none;
}
.markItUp a:link,
.markItUp a:visited {
color:#000;
text-decoration:none;
}
.markItUp {
width:700px;
margin:5px 0 5px 0;
border:5px solid #F5F5F5;
}
.markItUpContainer { .markItUpContainer {
border:1px solid #3C769D; background-image: url(chrome-extension://__MSG_@@extension_id__/images/markitup/skins/markitup/bg-container.png);
background:#FFF url(chrome-extension://__MSG_@@extension_id__/images/markitup/skins/markitup/bg-container.png) repeat-x top left;
padding:5px 5px 2px 5px;
font:11px Verdana, Arial, Helvetica, sans-serif;
} }
.markItUpEditor { .markItUpEditor {
font:12px 'Courier New', Courier, monospace; background: none;
padding:5px 5px 5px 5px/*35px*/; /* Padding fix */
border:3px solid #3C769D; padding-left: 10px;
width:643px;
height:320px;
/*background:#FFF url(chrome-extension://__MSG_@@extension_id__/images/markitup/skins/markitup/bg-editor.png) no-repeat;*/
clear:both;
line-height:18px;
overflow:auto;
}
.markItUpPreviewFrame {
overflow:auto;
background-color:#FFFFFF;
border:1px solid #3C769D;
width:99.9%;
height:300px;
margin:5px 0;
}
.markItUpFooter {
width:100%;
cursor:n-resize;
} }
.markItUpResizeHandle { .markItUpResizeHandle {
overflow:hidden; background-image:url(chrome-extension://__MSG_@@extension_id__/images/markitup/skins/markitup/handle.png);
width:22px; height:5px;
margin-left:auto;
margin-right:auto;
background-image:url(chrome-extension://__MSG_@@extension_id__/images/markitup/skins/markitup/handle.png);
cursor:n-resize;
} }
/***************************************************************************************/ /***************************************************************************************/
/* first row of buttons */ /* first row of buttons */
.markItUpHeader ul li {
list-style:none;
float:left;
position:relative;
}
.markItUpHeader ul li ul{
display:none;
}
.markItUpHeader ul li:hover > ul{
display:block;
}
.markItUpHeader ul .markItUpDropMenu { .markItUpHeader ul .markItUpDropMenu {
background:transparent url(chrome-extension://__MSG_@@extension_id__/images/markitup/skins/markitup/menu.png) no-repeat 115% 50%; background-image: url(chrome-extension://__MSG_@@extension_id__/images/markitup/skins/markitup/menu.png);
margin-right:5px;
}
.markItUpHeader ul .markItUpDropMenu li {
margin-right:0px;
}
.markItUpHeader ul .markItUpSeparator {
margin:0 10px;
width:1px;
height:16px;
overflow:hidden;
background-color:#CCC;
}
.markItUpHeader ul ul .markItUpSeparator {
width:auto; height:1px;
margin:0px;
}
/* next rows of buttons */
.markItUpHeader ul ul {
display:none;
position:absolute;
top:18px; left:0px;
background:#F5F5F5;
border:1px solid #3C769D;
height:inherit;
}
.markItUpHeader ul ul li {
float:none;
border-bottom:1px solid #3C769D;
} }
.markItUpHeader ul ul .markItUpDropMenu { .markItUpHeader ul ul .markItUpDropMenu {
background:#F5F5F5 url(chrome-extension://__MSG_@@extension_id__/images/markitup/skins/markitup/submenu.png) no-repeat 100% 50%; background-image: url(chrome-extension://__MSG_@@extension_id__/images/markitup/skins/markitup/submenu.png);
}
/* next rows of buttons */
.markItUpHeader ul ul ul {
position:absolute;
top:-1px; left:150px;
}
.markItUpHeader ul ul ul li {
float:none;
}
.markItUpHeader ul a {
display:block;
width:16px; height:16px;
text-indent:-10000px;
background-repeat:no-repeat;
padding:3px;
margin:0px;
}
.markItUpHeader ul ul a {
display:block;
padding-left:0px;
text-indent:0;
width:120px;
padding:5px 5px 5px 25px;
background-position:2px 50%;
}
.markItUpHeader ul ul a:hover {
color:#FFF;
background-color:#3C769D;
} }
/***************************************************************************************/ /***************************************************************************************/
.html .markItUpEditor { .html .markItUpEditor {
background-image:url(chrome-extension://__MSG_@@extension_id__/images/markitup/skins/markitup/bg-editor-html.png); background-image: url(chrome-extension://__MSG_@@extension_id__/images/markitup/skins/markitup/bg-editor-html.png);
} }
.markdown .markItUpEditor { .markdown .markItUpEditor {
background-image:url(chrome-extension://__MSG_@@extension_id__/images/markitup/skins/markitup/bg-editor-markdown.png); background-image: url(chrome-extension://__MSG_@@extension_id__/images/markitup/skins/markitup/bg-editor-markdown.png);
} }
.textile .markItUpEditor { .textile .markItUpEditor {
background-image:url(chrome-extension://__MSG_@@extension_id__/images/markitup/skins/markitup/bg-editor-textile.png); background-image: url(chrome-extension://__MSG_@@extension_id__/images/markitup/skins/markitup/bg-editor-textile.png);
} }
.bbcode .markItUpEditor { .bbcode .markItUpEditor {
background-image:url(chrome-extension://__MSG_@@extension_id__/images/markitup/skins/markitup/bg-editor-bbcode.png); background-image: url(chrome-extension://__MSG_@@extension_id__/images/markitup/skins/markitup/bg-editor-bbcode.png);
} }
.wiki .markItUpEditor, .wiki .markItUpEditor,
.dotclear .markItUpEditor { .dotclear .markItUpEditor {
background-image:url(chrome-extension://__MSG_@@extension_id__/images/markitup/skins/markitup/bg-editor-wiki.png); background-image: url(chrome-extension://__MSG_@@extension_id__/images/markitup/skins/markitup/bg-editor-wiki.png);
} }

View File

@ -163,34 +163,4 @@ div#markItUpText-input {
#comments .post:hover .nesting { #comments .post:hover .nesting {
background-repeat: repeat-x; background-repeat: repeat-x;
background-image: url('chrome-extension://__MSG_@@extension_id__/images/nesting-point.png'); background-image: url('chrome-extension://__MSG_@@extension_id__/images/nesting-point.png');
}
/* Fancybox fix */
#fancybox-loading, .fancybox-close, .fancybox-prev span, .fancybox-next span {
background-image: url('chrome-extension://__MSG_@@extension_id__/vendor/fancybox/source/fancybox_sprite.png');
}
#fancybox-loading div {
background: url('chrome-extension://__MSG_@@extension_id__/vendor/fancybox/source/fancybox_loading.gif') center center no-repeat;
}
.fancybox-nav {
background: transparent url('chrome-extension://__MSG_@@extension_id__/vendor/fancybox/source/chrome-extension://__MSG_@@extension_id__/vendor/fancybox/source/blank.gif'); /* helps IE */
}
.fancybox-overlay {
background: url('chrome-extension://__MSG_@@extension_id__/vendor/fancybox/source/chrome-extension://__MSG_@@extension_id__/vendor/fancybox/source/fancybox_overlay.png');
}
@media only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (min--moz-device-pixel-ratio: 1.5),
only screen and (min-device-pixel-ratio: 1.5) {
#fancybox-loading, .fancybox-close, .fancybox-prev span, .fancybox-next span {
background-image: url('chrome-extension://__MSG_@@extension_id__/vendor/fancybox/source/chrome-extension://__MSG_@@extension_id__/vendor/fancybox/source/fancybox_sprite@2x.png');
}
#fancybox-loading div {
background-image: url('chrome-extension://__MSG_@@extension_id__/vendor/fancybox/source/chrome-extension://__MSG_@@extension_id__/vendor/fancybox/source/fancybox_loading@2x.gif');
}
} }

View File

@ -8,15 +8,50 @@ chrome.storage.sync.get('options_version', function(data) {
} }
}); });
// Crutches and bikes
/**
* Inject several JS files
* @param {number} tabId Unique ID of tab which requested injection
* @param {Object[]} files Array of objects of files to inject
* @param {function} onAllInjected allback function running when injection ends
*/
function injectJS(tabId, files, onAllInjected) {
var item = files.shift();
if (item) {
console.log('Injecting JS "%s" to the tab #%s', item.file, tabId);
if ('file' in item) {
chrome.tabs.executeScript(tabId ? tabId : null, {
file: item.file,
runAt: item.runAt || 'document_start'
}, function(result) {
console.info('"%s" injected to the tab #%s', item.file, tabId);
injectJS(tabId, files, onAllInjected);
});
}
} else {
onAllInjected();
}
}
// @todo Implement injectCSS (because JS execution working always after CSS injection)
// Message listener // Message listener
chrome.extension.onMessage.addListener(function(message, sender) { chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) {
console.log('Received message: %O', message); // @todo Check if sender.tab may be undefined in some cases
console.log('Received message from tab #%i: %O', sender.tab.id, message);
if (message) { if (message) {
switch (message.type) { switch (message.type) {
case 'showPageAction': case 'showPageAction':
var tab = sender.tab; chrome.pageAction.show(sender.tab.id);
chrome.pageAction.show(tab.id); sendResponse(true);
console.log('Showed pageAction for tab #%s', sender.tab.id);
// Fuck You, Chrome API documentation!!11
return true;
break; break;
case 'showNotification': case 'showNotification':
@ -28,11 +63,15 @@ chrome.extension.onMessage.addListener(function(message, sender) {
message: message.text, message: message.text,
priority: 0, priority: 0,
isClickable: true isClickable: true
}, }, function(notificationId) {
function() { /* Error checking goes here */} console.info('Notification "%s" created', notificationId);
sendResponse(true);
}
); );
console.log('Showing notification %s', message.notificationId); // Fuck You, Chrome API documentation!!11
return true;
break; break;
case 'listenNotificationClicks': case 'listenNotificationClicks':
@ -52,30 +91,95 @@ chrome.extension.onMessage.addListener(function(message, sender) {
}); });
} }
}); });
break;
sendResponse(true);
// Fuck You, Chrome API documentation!
return true;
break;
/**
* @deprecated since 1.19.1
*/
case 'injectJSFile': case 'injectJSFile':
console.log('Injecting JS: %s', message.file); console.log('Executing JS: %s', message.file);
chrome.tabs.executeScript(null, { chrome.tabs.executeScript(sender.tab.id ? sender.tab.id : null, {
file: message.file file: message.file,
//,runAt: 'document_end' runAt: message.runAt || 'document_start'
}, function() {
sendResponse(true);
console.info('JS file executed: "%s"', message.file);
return true;
}); });
// Fuck You, Chrome API documentation!
return true;
break; break;
// Inject several files
case 'executeJSFiles':
//console.debug('Received JS file list: %O', message.files);
if (message.files.length) {
injectJS(sender.tab.id ? sender.tab.id : null, message.files, function() {
// @fixme does not sending response now!
console.info('All scripts executed');
sendResponse(true);
return true;
});
} else {
/*
* May be not?
* But I don't want to block some shit-code execution
*/
sendResponse(false);
console.warn('No scripts executed (empty script array)');
}
// Fuck You, Chrome API documentation!
return true;
break;
/**
* @deprecated since 1.19.1
*/
case 'injectCSSFile': case 'injectCSSFile':
console.log('Injecting CSS: %s', message.file); console.log('Injecting CSS: "%s"', message.file);
chrome.tabs.insertCSS(null, { chrome.tabs.insertCSS(sender.tab.id ? sender.tab.id : null, {
file: message.file file: message.file
}, function() {
// @todo message response callback processing
//sendResponse(true);
console.info('CSS file "%s" injected', message.file);
}); });
// Fuck You, Chrome API documentation!
return true;
break; break;
case 'injectCSSCode': case 'injectCSSCode':
if (message.code !== undefined) { if (message.code !== undefined) {
chrome.tabs.insertCSS(null, { chrome.tabs.insertCSS(sender.tab.id ? sender.tab.id : null, {
code: message.code code: message.code
}, function() {
// @todo message response callback processing
//sendResponse(true);
console.info('CSS code injected: \n%s', message.file);
}); });
} }
// Fuck You, Chrome API documentation!
return true;
break;
default:
sendResponse(false);
return true;
break; break;
} }
} }

View File

@ -1,6 +1,8 @@
// Showing page action // Showing page action
chrome.extension.sendMessage({ chrome.runtime.sendMessage({
type: 'showPageAction' type: 'showPageAction'
}, null, function(response) {
console.debug('showPageAction response: %O', response);
}); });
/** /**
@ -68,7 +70,7 @@ $(document).ready(function() {
// Options debug // Options debug
try { try {
console.debug('Options loaded: %O', options.getOptions()); console.debug('Options loaded: %O', options.getOptions());
}catch(e){} } catch(e){}
create_tag_system(); create_tag_system();
// Embedding // Embedding
@ -94,38 +96,44 @@ $(document).ready(function() {
// Soundcloud // Soundcloud
if (options.is('option_embedding_soundcloud')) { if (options.is('option_embedding_soundcloud')) {
// Injecting JS API // Executing Soundcloud player JS API
chrome.extension.sendMessage({ chrome.runtime.sendMessage({
type: 'injectJSFile', type: 'executeJSFiles',
file: 'vendor/soundcloud/soundcloud.player.api.js' files: [{
}); file: 'vendor/soundcloud/soundcloud.player.api.js',
runAt: 'document_end'
}]
}, null, function(response) {
console.debug('Soundcloud injection response: %O', response);
// If scripts are executed
if (response) {
// Processing links
$('.post .post-content a[href*="\\:\\/\\/soundcloud\\.com\\/"]').each(function(index) {
console.log($(this));
// Processing links // @todo: вынести в отдельный шаблон
$('.post .post-content a[href*="\\:\\/\\/soundcloud\\.com\\/"]').each(function(index) { $player = $('<div class="pp-soundcloud">\
console.log($(this)); <object height="81" width="100%" id="pp-soundcloud-' + index + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">\
<param name="movie" value="//player.soundcloud.com/player.swf?url=' + encodeURIComponent($(this).prop('href'))
+ '&enable_api=true&object_id=pp-soundcloud-' + index + '">\
<param name="allowscriptaccess" value="always">\
<embed allowscriptaccess="always" height="81" src="//player.soundcloud.com/player.swf?url='
+ encodeURIComponent($(this).prop('href')) + '&enable_api=true&object_id=pp-soundcloud-' + index
+ '" type="application/x-shockwave-flash" width="100%" name="pp-soundcloud-' + index + '"></embed>\
</object>\
</div>');
// @todo: вынести в отдельный шаблон // Replace or prepend
$player = $('<div class="pp-soundcloud">\ if (options.is('option_embedding_soundcloud_orig_link')) {
<object height="81" width="100%" id="pp-soundcloud-' + index + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">\ // Before
<param name="movie" value="//player.soundcloud.com/player.swf?url=' + encodeURIComponent($(this).prop('href')) $(this).before($player);
+ '&enable_api=true&object_id=pp-soundcloud-' + index + '">\ } else {
<param name="allowscriptaccess" value="always">\ // Replace
<embed allowscriptaccess="always" height="81" src="//player.soundcloud.com/player.swf?url=' $(this).replaceWith($player);
+ encodeURIComponent($(this).prop('href')) + '&enable_api=true&object_id=pp-soundcloud-' + index }
+ '" type="application/x-shockwave-flash" width="100%" name="pp-soundcloud-' + index + '"></embed>\ });
</object>\
</div>');
// Replace or prepend
if (options.is('option_embedding_soundcloud_orig_link')) {
// Before
$(this).before($player);
} else {
// Replace
$(this).replaceWith($player);
} }
}); });
} }
// Parse pleer.com links and create audio instead // Parse pleer.com links and create audio instead
@ -142,66 +150,83 @@ $(document).ready(function() {
// Fancybox // Fancybox
if (options.is('option_fancybox')) { if (options.is('option_fancybox')) {
// Injecting Fancybox to the page // Injecting Fancybox to the page
chrome.extension.sendMessage({ // CSS
type: 'injectJSFile', // @todo message response callback processing
file: 'vendor/fancybox/source/jquery.fancybox.pack.js' chrome.runtime.sendMessage({
});
chrome.extension.sendMessage({
type: 'injectJSFile',
file: 'vendor/fancybox/source/helpers/jquery.fancybox-media.js'
});
chrome.extension.sendMessage({
type: 'injectCSSFile', type: 'injectCSSFile',
file: 'vendor/fancybox/source/jquery.fancybox.css' file: 'vendor/fancybox/source/jquery.fancybox.css'
}); });
// @todo message response callback processing
if (options.is('option_fancybox_bind_images_to_one_flow')) { chrome.runtime.sendMessage({
// Linking images in posts to the galleries type: 'injectCSSFile',
$('.post-content .text').each(function() { file: 'css/fancybox/style.css'
$(this).find('a.postimg:not(.youtube)').attr('data-fancybox-group', 'one_flow_gallery'); });
}); // JS
} else { chrome.runtime.sendMessage(null, {
$('.post-content .text').each(function(idxPost) { type: 'executeJSFiles',
$(this).find('a.postimg:not(.youtube)').attr('data-fancybox-group', 'post' + idxPost); files: [{
}); file: 'vendor/fancybox/source/jquery.fancybox.pack.js',
} runAt: 'document_end'
}, {
// @todo Move to the option_fancybox_videos section
file: 'vendor/fancybox/source/helpers/jquery.fancybox-media.js',
runAt: 'document_end'
}]
}, null, function(response) {
// If all JS are executed
console.debug('Fancybox injection response: %O', response);
if (response) {
console.log('Fancybox executed. Processing...');
if (options.is('option_fancybox_bind_images_to_one_flow')) {
// Linking images in posts to the galleries
$('.post-content .text').each(function() {
$(this).find('a.postimg:not(.youtube)').attr('data-fancybox-group', 'one_flow_gallery');
});
} else {
$('.post-content .text').each(function(idxPost) {
$(this).find('a.postimg:not(.youtube)').attr('data-fancybox-group', 'post' + idxPost);
});
}
// Images // Images
if (options.is('option_fancybox_images')) { if (options.is('option_fancybox_images')) {
// Init fancybox // Init fancybox
$('.postimg:not(.youtube)').fancybox({ $('.postimg:not(.youtube)').fancybox({
type: 'image' type: 'image'
}); });
} }
// Правим хинты у фансибокса // Правим хинты у фансибокса
if (options.is('option_fancybox_smart_hints')) { if (options.is('option_fancybox_smart_hints')) {
fancybox_set_smart_hints(); fancybox_set_smart_hints();
} else { } else {
$('.post .postimg').attr('data-fancybox-title', ' '); $('.post .postimg').attr('data-fancybox-title', ' ');
} }
// Videos // Videos
if (options.is('option_fancybox_videos')) { if (options.is('option_fancybox_videos')) {
$('.postimg.youtube').addClass('fancybox-media').fancybox({ $('.postimg.youtube').addClass('fancybox-media').fancybox({
helpers: { helpers: {
media: { media: {
youtube: { youtube: {
params: { params: {
autoplay: 1 autoplay: 1
}
}
} }
} }
} });
} }
}); // Posts
} if (options.is('option_fancybox_posts')) {
// Posts // Excluding some sort of piece-of-shit makeup
if (options.is('option_fancybox_posts')) { $('.post-id a').not('#comments .post-id a, #top-post .post-id a').attr('data-fancybox-type', 'iframe').fancybox({
// Excluding some sort of piece-of-shit makeup maxWidth: 780
$('.post-id a').not('#comments .post-id a, #top-post .post-id a').attr('data-fancybox-type', 'iframe').fancybox({ });
maxWidth: 780 }
}); }
} });
} }
// NSFW Filtering // NSFW Filtering
@ -282,41 +307,55 @@ $(document).ready(function() {
} }
// Visual editor // Visual editor
if (options.is('option_visual_editor_post')) { if (options.is('option_visual_editor_post')) {
// Injecting editor JS // Add classes
chrome.extension.sendMessage({ $('#new-post-form #text-input, .post-content #text-input').addClass('markitup').css('height', '20em');
type: 'injectJSFile',
file: 'vendor/markitup/markitup/jquery.markitup.js'
});
// Getting mySettings from set.js
chrome.extension.sendMessage({
type: 'injectJSFile',
file: 'js/markitup/sets/markdown/set.js'
});
// CSS // CSS
chrome.extension.sendMessage({ // @todo message response callback processing
chrome.runtime.sendMessage({
type: 'injectCSSFile', type: 'injectCSSFile',
file: 'vendor/markitup/markitup/skins/markitup/style.css' file: 'vendor/markitup/markitup/skins/markitup/style.css'
}); });
chrome.extension.sendMessage({ // Fixes for extension
// @todo message response callback processing
chrome.runtime.sendMessage({
type: 'injectCSSFile',
file: 'css/markitup/skins/markitup/style.css'
});
// @todo message response callback processing
chrome.runtime.sendMessage({
type: 'injectCSSFile', type: 'injectCSSFile',
file: 'css/markitup/sets/markdown/style.css' file: 'css/markitup/sets/markdown/style.css'
}); });
// JS
// Add classes chrome.runtime.sendMessage({
$('#new-post-form #text-input, .post-content #text-input').addClass('markitup').css('height', '20em'); type: 'executeJSFiles',
// Init files: [{
$('.markitup').markItUp(mySettings); file: 'vendor/markitup/markitup/jquery.markitup.js',
runAt: 'document_end'
}, {
file: 'js/markitup/sets/markdown/set.js',
runAt: 'document_end'
}]
}, null, function(response) {
console.debug('MarkItUp injection response: %O', response);
// If scripts are executed
if (response) {
// Init MarkItUp
$('.markitup').markItUp(mySettings);
// Send by CTRL+Enter // Send by CTRL+Enter
if (options.is('option_ctrl_enter')) { if (options.is('option_ctrl_enter')) {
// 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();
}
});
} }
}); }
} });
} }
// Google search // Google search
if (options.is('option_search_with_google')) { if (options.is('option_search_with_google')) {
@ -335,7 +374,7 @@ $(document).ready(function() {
// @todo: унести в опцию // @todo: унести в опцию
// Adding event listener for notification click // Adding event listener for notification click
chrome.extension.sendMessage({ chrome.runtime.sendMessage({
type: 'listenNotificationClicks', type: 'listenNotificationClicks',
protocol: getProtocol() protocol: getProtocol()
}); });
@ -357,7 +396,7 @@ $(document).ready(function() {
try { try {
// ping :) // ping :)
if (evt.data == 'ping') { if (evt.data == 'ping') {
console.debug('ws-ping'); console.info('ws-ping');
} else { } else {
var wsMessage = JSON.parse(evt.data); var wsMessage = JSON.parse(evt.data);
@ -491,7 +530,7 @@ $(document).ready(function() {
// Desktop notifications // Desktop notifications
if (options.is('option_ws_comments_notifications')) { if (options.is('option_ws_comments_notifications')) {
console.log('Showing desktop notification'); console.log('Showing desktop notification');
chrome.extension.sendMessage({ chrome.runtime.sendMessage({
type: 'showNotification', type: 'showNotification',
notificationId: 'comment_' + wsMessage.post_id + '#' + wsMessage.comment_id, notificationId: 'comment_' + wsMessage.post_id + '#' + wsMessage.comment_id,
avatarUrl: getProtocol() + userAvatar + '/80', avatarUrl: getProtocol() + userAvatar + '/80',
@ -550,7 +589,8 @@ $(document).ready(function() {
} }
// @ before username // @ before username
if (options.is('option_at_before_username')) { if (options.is('option_at_before_username')) {
chrome.extension.sendMessage({ // @todo message response callback processing
chrome.runtime.sendMessage({
type: 'injectCSSFile', type: 'injectCSSFile',
file: 'css/modules/at_before_username.css' file: 'css/modules/at_before_username.css'
}); });
@ -594,7 +634,7 @@ $(document).ready(function() {
}); });
function getProtocol() { function getProtocol() {
return ((location.protocol == 'http:') ? 'http:' : 'https:') return ((location.protocol == 'http:') ? 'http:' : 'https:');
} }
function escapeHtml(text) { function escapeHtml(text) {

View File

@ -44,6 +44,7 @@
"web_accessible_resources": [ "web_accessible_resources": [
"images/*", "images/*",
"includes/*", "includes/*",
"vendor/*",
"manifest.json" "manifest.json"
], ],
"background": { "background": {