From 180d58b464e164694031c0665d38f63e024e2b97 Mon Sep 17 00:00:00 2001 From: Alexey Skobkin Date: Wed, 7 Jan 2015 06:36:06 +0400 Subject: [PATCH 1/8] Non-working dynamic loading system and new message API. --- chrome_point_plus/js/background.js | 106 +++++++++++-- chrome_point_plus/js/point-plus.js | 245 ++++++++++++++++------------- 2 files changed, 226 insertions(+), 125 deletions(-) diff --git a/chrome_point_plus/js/background.js b/chrome_point_plus/js/background.js index 6acddc7..34c6306 100644 --- a/chrome_point_plus/js/background.js +++ b/chrome_point_plus/js/background.js @@ -8,15 +8,47 @@ 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 + * @callback onAllInjected Callback 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 -chrome.extension.onMessage.addListener(function(message, sender) { - console.log('Received message: %O', message); +chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) { + // @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) { switch (message.type) { case 'showPageAction': - var tab = sender.tab; - chrome.pageAction.show(tab.id); + chrome.pageAction.show(sender.tab.id); + sendResponse(true); + + console.log('Showed pageAction for tab #%s', sender.tab.id); break; case 'showNotification': @@ -28,11 +60,13 @@ chrome.extension.onMessage.addListener(function(message, sender) { message: message.text, priority: 0, isClickable: true - }, - function() { /* Error checking goes here */} + }, function(notificationId) { + console.info('Notification "%s" created', notificationId); + + sendResponse(true); + } ); - console.log('Showing notification %s', message.notificationId); break; case 'listenNotificationClicks': @@ -52,27 +86,69 @@ chrome.extension.onMessage.addListener(function(message, sender) { }); } }); - break; + sendResponse(true); + break; + + /** + * @deprecated since 1.19.1 + */ case 'injectJSFile': - console.log('Injecting JS: %s', message.file); - chrome.tabs.executeScript(null, { - file: message.file - //,runAt: 'document_end' + console.log('Executing JS: %s', message.file); + chrome.tabs.executeScript(sender.tab.id ? sender.tab.id : null, { + file: message.file, + runAt: message.runAt || 'document_start' + }, function() { + sendResponse(true); + + console.info('JS file executed: "%s"', message.file); }); 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! + sendResponse(true); + + console.info('All scripts executed'); + }); + } 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)'); + } + break; + + /** + * @deprecated since 1.19.1 + */ case 'injectCSSFile': - console.log('Injecting CSS: %s', message.file); - chrome.tabs.insertCSS(null, { + console.log('Injecting CSS: "%s"', message.file); + chrome.tabs.insertCSS(sender.tab.id ? sender.tab.id : null, { file: message.file + }, function() { + sendResponse(true); + + console.info('CSS file "%s" injected', message.file); }); break; case 'injectCSSCode': if (message.code !== undefined) { - chrome.tabs.insertCSS(null, { + chrome.tabs.insertCSS(sender.tab.id ? sender.tab.id : null, { code: message.code + }, function() { + sendResponse(true); + + console.info('CSS code injected: \n%s', message.file); }); } diff --git a/chrome_point_plus/js/point-plus.js b/chrome_point_plus/js/point-plus.js index 1250eb7..f13a0b0 100644 --- a/chrome_point_plus/js/point-plus.js +++ b/chrome_point_plus/js/point-plus.js @@ -1,6 +1,8 @@ // Showing page action -chrome.extension.sendMessage({ +chrome.runtime.sendMessage({ type: 'showPageAction' +}, null, function(response) { + console.debug('showPageAction response: %O', response); }); /** @@ -68,7 +70,7 @@ $(document).ready(function() { // Options debug try { console.debug('Options loaded: %O', options.getOptions()); - }catch(e){} + } catch(e){} create_tag_system(); // Embedding @@ -94,38 +96,44 @@ $(document).ready(function() { // Soundcloud if (options.is('option_embedding_soundcloud')) { - // Injecting JS API - chrome.extension.sendMessage({ - type: 'injectJSFile', - file: 'vendor/soundcloud/soundcloud.player.api.js' - }); + // Executing Soundcloud player JS API + chrome.runtime.sendMessage({ + type: 'executeJSFiles', + 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 - $('.post .post-content a[href*="\\:\\/\\/soundcloud\\.com\\/"]').each(function(index) { - console.log($(this)); + // @todo: вынести в отдельный шаблон + $player = $('
\ + \ + \ + \ + \ + \ +
'); - // @todo: вынести в отдельный шаблон - $player = $('
\ - \ - \ - \ - \ - \ -
'); - - // Replace or prepend - if (options.is('option_embedding_soundcloud_orig_link')) { - // Before - $(this).before($player); - } else { - // Replace - $(this).replaceWith($player); + // 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 @@ -142,66 +150,77 @@ $(document).ready(function() { // Fancybox if (options.is('option_fancybox')) { // Injecting Fancybox to the page - chrome.extension.sendMessage({ - type: 'injectJSFile', - file: 'vendor/fancybox/source/jquery.fancybox.pack.js' - }); - chrome.extension.sendMessage({ - type: 'injectJSFile', - file: 'vendor/fancybox/source/helpers/jquery.fancybox-media.js' - }); - chrome.extension.sendMessage({ + // CSS + chrome.runtime.sendMessage({ type: 'injectCSSFile', file: 'vendor/fancybox/source/jquery.fancybox.css' }); - - 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); - }); - } + // JS + chrome.runtime.sendMessage(null, { + type: 'executeJSFiles', + 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 - if (options.is('option_fancybox_images')) { - // Init fancybox - $('.postimg:not(.youtube)').fancybox({ - type: 'image' - }); - } + // Images + if (options.is('option_fancybox_images')) { + // Init fancybox + $('.postimg:not(.youtube)').fancybox({ + type: 'image' + }); + } - // Правим хинты у фансибокса - if (options.is('option_fancybox_smart_hints')) { - fancybox_set_smart_hints(); - } else { - $('.post .postimg').attr('data-fancybox-title', ' '); - } + // Правим хинты у фансибокса + if (options.is('option_fancybox_smart_hints')) { + fancybox_set_smart_hints(); + } else { + $('.post .postimg').attr('data-fancybox-title', ' '); + } - // Videos - if (options.is('option_fancybox_videos')) { - $('.postimg.youtube').addClass('fancybox-media').fancybox({ - helpers: { - media: { - youtube: { - params: { - autoplay: 1 + // Videos + if (options.is('option_fancybox_videos')) { + $('.postimg.youtube').addClass('fancybox-media').fancybox({ + helpers: { + media: { + youtube: { + params: { + autoplay: 1 + } + } } } - } + }); } - }); - } - // Posts - if (options.is('option_fancybox_posts')) { - // Excluding some sort of piece-of-shit makeup - $('.post-id a').not('#comments .post-id a, #top-post .post-id a').attr('data-fancybox-type', 'iframe').fancybox({ - maxWidth: 780 - }); - } + // Posts + if (options.is('option_fancybox_posts')) { + // Excluding some sort of piece-of-shit makeup + $('.post-id a').not('#comments .post-id a, #top-post .post-id a').attr('data-fancybox-type', 'iframe').fancybox({ + maxWidth: 780 + }); + } + } + }); } // NSFW Filtering @@ -282,41 +301,47 @@ $(document).ready(function() { } // Visual editor if (options.is('option_visual_editor_post')) { - // Injecting editor JS - chrome.extension.sendMessage({ - 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' - }); + // Add classes + $('#new-post-form #text-input, .post-content #text-input').addClass('markitup').css('height', '20em'); + // CSS - chrome.extension.sendMessage({ + chrome.runtime.sendMessage({ type: 'injectCSSFile', file: 'vendor/markitup/markitup/skins/markitup/style.css' }); - chrome.extension.sendMessage({ + chrome.runtime.sendMessage({ type: 'injectCSSFile', file: 'css/markitup/sets/markdown/style.css' }); - - // Add classes - $('#new-post-form #text-input, .post-content #text-input').addClass('markitup').css('height', '20em'); - // Init - $('.markitup').markItUp(mySettings); + // JS + chrome.runtime.sendMessage({ + type: 'executeJSFiles', + files: [{ + 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 - if (options.is('option_ctrl_enter')) { - // New post - $('#new-post-form #text-input, .post-content #text-input').on('keydown.point_plus', function(e) { - if (e.ctrlKey && (e.keyCode == 10 || e.keyCode == 13)) { - e.preventDefault(); - $(this).parents('#new-post-form,#post-edit-form').submit(); + // Send by CTRL+Enter + if (options.is('option_ctrl_enter')) { + // New post + $('#new-post-form #text-input, .post-content #text-input').on('keydown.point_plus', function(e) { + if (e.ctrlKey && (e.keyCode == 10 || e.keyCode == 13)) { + e.preventDefault(); + $(this).parents('#new-post-form,#post-edit-form').submit(); + } + }); } - }); - } + } + }); } // Google search if (options.is('option_search_with_google')) { @@ -335,7 +360,7 @@ $(document).ready(function() { // @todo: унести в опцию // Adding event listener for notification click - chrome.extension.sendMessage({ + chrome.runtime.sendMessage({ type: 'listenNotificationClicks', protocol: getProtocol() }); @@ -491,7 +516,7 @@ $(document).ready(function() { // Desktop notifications if (options.is('option_ws_comments_notifications')) { console.log('Showing desktop notification'); - chrome.extension.sendMessage({ + chrome.runtime.sendMessage({ type: 'showNotification', notificationId: 'comment_' + wsMessage.post_id + '#' + wsMessage.comment_id, avatarUrl: getProtocol() + userAvatar + '/80', @@ -550,7 +575,7 @@ $(document).ready(function() { } // @ before username if (options.is('option_at_before_username')) { - chrome.extension.sendMessage({ + chrome.runtime.sendMessage({ type: 'injectCSSFile', file: 'css/modules/at_before_username.css' }); From 93a24c57d483d541a1e237541a70436dfc52fbe0 Mon Sep 17 00:00:00 2001 From: Alexey Skobkin Date: Wed, 7 Jan 2015 08:19:02 +0400 Subject: [PATCH 2/8] Fuck You, Chrome API documentation!!11 --- chrome_point_plus/js/background.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/chrome_point_plus/js/background.js b/chrome_point_plus/js/background.js index 34c6306..9df711e 100644 --- a/chrome_point_plus/js/background.js +++ b/chrome_point_plus/js/background.js @@ -49,6 +49,9 @@ chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) { sendResponse(true); console.log('Showed pageAction for tab #%s', sender.tab.id); + + // Fuck You, Chrome API documentation!!11 + return true; break; case 'showNotification': @@ -67,6 +70,8 @@ chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) { } ); + // Fuck You, Chrome API documentation!!11 + return true; break; case 'listenNotificationClicks': @@ -88,6 +93,9 @@ chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) { }); sendResponse(true); + + // Fuck You, Chrome API documentation!!11 + return true; break; /** @@ -103,6 +111,9 @@ chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) { console.info('JS file executed: "%s"', message.file); }); + + // Fuck You, Chrome API documentation!!11 + return true; break; // Inject several files @@ -112,9 +123,11 @@ chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) { 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); - console.info('All scripts executed'); + return true; }); } else { /* @@ -125,6 +138,9 @@ chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) { console.warn('No scripts executed (empty script array)'); } + + // Fuck You, Chrome API documentation!!11 + return true; break; /** @@ -139,6 +155,9 @@ chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) { console.info('CSS file "%s" injected', message.file); }); + + // Fuck You, Chrome API documentation!!11 + return true; break; case 'injectCSSCode': @@ -152,6 +171,8 @@ chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) { }); } + // Fuck You, Chrome API documentation!!11 + return true; break; } } From 0dae3f86614f27f9e45cd3cc403a7a98b2169901 Mon Sep 17 00:00:00 2001 From: Alexey Skobkin Date: Wed, 7 Jan 2015 08:43:17 +0400 Subject: [PATCH 3/8] Moar fixes. --- chrome_point_plus/js/background.js | 23 +++++++++++++++-------- chrome_point_plus/js/point-plus.js | 4 ++++ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/chrome_point_plus/js/background.js b/chrome_point_plus/js/background.js index 9df711e..d4fe28d 100644 --- a/chrome_point_plus/js/background.js +++ b/chrome_point_plus/js/background.js @@ -94,7 +94,7 @@ chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) { sendResponse(true); - // Fuck You, Chrome API documentation!!11 + // Fuck You, Chrome API documentation! return true; break; @@ -110,9 +110,10 @@ chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) { sendResponse(true); console.info('JS file executed: "%s"', message.file); + return true; }); - // Fuck You, Chrome API documentation!!11 + // Fuck You, Chrome API documentation! return true; break; @@ -126,7 +127,6 @@ chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) { console.info('All scripts executed'); sendResponse(true); - return true; }); } else { @@ -139,7 +139,7 @@ chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) { console.warn('No scripts executed (empty script array)'); } - // Fuck You, Chrome API documentation!!11 + // Fuck You, Chrome API documentation! return true; break; @@ -151,12 +151,13 @@ chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) { chrome.tabs.insertCSS(sender.tab.id ? sender.tab.id : null, { file: message.file }, function() { - sendResponse(true); + // @todo message response callback processing + //sendResponse(true); console.info('CSS file "%s" injected', message.file); }); - // Fuck You, Chrome API documentation!!11 + // Fuck You, Chrome API documentation! return true; break; @@ -165,13 +166,19 @@ chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) { chrome.tabs.insertCSS(sender.tab.id ? sender.tab.id : null, { code: message.code }, function() { - sendResponse(true); + // @todo message response callback processing + //sendResponse(true); console.info('CSS code injected: \n%s', message.file); }); } - // Fuck You, Chrome API documentation!!11 + // Fuck You, Chrome API documentation! + return true; + break; + + default: + sendResponse(false); return true; break; } diff --git a/chrome_point_plus/js/point-plus.js b/chrome_point_plus/js/point-plus.js index f13a0b0..5012006 100644 --- a/chrome_point_plus/js/point-plus.js +++ b/chrome_point_plus/js/point-plus.js @@ -151,6 +151,7 @@ $(document).ready(function() { if (options.is('option_fancybox')) { // Injecting Fancybox to the page // CSS + // @todo message response callback processing chrome.runtime.sendMessage({ type: 'injectCSSFile', file: 'vendor/fancybox/source/jquery.fancybox.css' @@ -305,10 +306,12 @@ $(document).ready(function() { $('#new-post-form #text-input, .post-content #text-input').addClass('markitup').css('height', '20em'); // CSS + // @todo message response callback processing chrome.runtime.sendMessage({ type: 'injectCSSFile', file: 'vendor/markitup/markitup/skins/markitup/style.css' }); + // @todo message response callback processing chrome.runtime.sendMessage({ type: 'injectCSSFile', file: 'css/markitup/sets/markdown/style.css' @@ -575,6 +578,7 @@ $(document).ready(function() { } // @ before username if (options.is('option_at_before_username')) { + // @todo message response callback processing chrome.runtime.sendMessage({ type: 'injectCSSFile', file: 'css/modules/at_before_username.css' From 27e97f138b95cfc890627290e06b684a5f1dde2f Mon Sep 17 00:00:00 2001 From: Alexey Skobkin Date: Wed, 7 Jan 2015 08:57:23 +0400 Subject: [PATCH 4/8] Bower's MarkItUp CSS fix. --- .../css/markitup/skins/markitup/style.css | 135 ++---------------- chrome_point_plus/js/point-plus.js | 6 + 2 files changed, 18 insertions(+), 123 deletions(-) diff --git a/chrome_point_plus/css/markitup/skins/markitup/style.css b/chrome_point_plus/css/markitup/skins/markitup/style.css index fd86683..630a175 100644 --- a/chrome_point_plus/css/markitup/skins/markitup/style.css +++ b/chrome_point_plus/css/markitup/skins/markitup/style.css @@ -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 { - border:1px solid #3C769D; - 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; + background:#FFF url(chrome-extension://__MSG_@@extension_id__/images/markitup/skins/markitup/bg-container.png) repeat-x top left; } .markItUpEditor { - font:12px 'Courier New', Courier, monospace; - padding:5px 5px 5px 5px/*35px*/; - border:3px solid #3C769D; - 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; + background: none; + /* Padding fix */ + padding-left: 10px; } .markItUpResizeHandle { - overflow:hidden; - 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; + background-image:url(chrome-extension://__MSG_@@extension_id__/images/markitup/skins/markitup/handle.png); } /***************************************************************************************/ /* 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 { - background:transparent url(chrome-extension://__MSG_@@extension_id__/images/markitup/skins/markitup/menu.png) no-repeat 115% 50%; - 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; + background:transparent url(chrome-extension://__MSG_@@extension_id__/images/markitup/skins/markitup/menu.png) no-repeat 115% 50%; } .markItUpHeader ul ul .markItUpDropMenu { - background:#F5F5F5 url(chrome-extension://__MSG_@@extension_id__/images/markitup/skins/markitup/submenu.png) no-repeat 100% 50%; -} -/* 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; + background:#F5F5F5 url(chrome-extension://__MSG_@@extension_id__/images/markitup/skins/markitup/submenu.png) no-repeat 100% 50%; } /***************************************************************************************/ .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 { - 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 { - 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 { - 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, .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); } \ No newline at end of file diff --git a/chrome_point_plus/js/point-plus.js b/chrome_point_plus/js/point-plus.js index 5012006..aba2d9d 100644 --- a/chrome_point_plus/js/point-plus.js +++ b/chrome_point_plus/js/point-plus.js @@ -311,6 +311,12 @@ $(document).ready(function() { type: 'injectCSSFile', file: 'vendor/markitup/markitup/skins/markitup/style.css' }); + // 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', From 8f9d880cb2c1b47f38901af1917ff628eff4adba Mon Sep 17 00:00:00 2001 From: Alexey Skobkin Date: Wed, 7 Jan 2015 09:11:05 +0400 Subject: [PATCH 5/8] Bower's Fancybox CSS fix. --- chrome_point_plus/css/fancybox/style.css | 60 ++++++++++++++++++++++++ chrome_point_plus/css/point-plus.css | 30 ------------ chrome_point_plus/js/point-plus.js | 5 ++ chrome_point_plus/manifest.json | 1 + 4 files changed, 66 insertions(+), 30 deletions(-) create mode 100644 chrome_point_plus/css/fancybox/style.css diff --git a/chrome_point_plus/css/fancybox/style.css b/chrome_point_plus/css/fancybox/style.css new file mode 100644 index 0000000..e6931de --- /dev/null +++ b/chrome_point_plus/css/fancybox/style.css @@ -0,0 +1,60 @@ +/* + 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: 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/blank.gif'); /* helps IE */ +} +.fancybox-overlay { + background: url('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/fancybox_sprite@2x.png'); + } + + #fancybox-loading div { + background-image: url('chrome-extension://__MSG_@@extension_id__/vendor/fancybox/source/fancybox_loading@2x.gif'); + } +}/* 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/blank.gif'); /* helps IE */ +} +.fancybox-overlay { + background: url('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/fancybox_sprite@2x.png'); + } + + #fancybox-loading div { + background-image: url('chrome-extension://__MSG_@@extension_id__/vendor/fancybox/source/fancybox_loading@2x.gif'); + } +} \ No newline at end of file diff --git a/chrome_point_plus/css/point-plus.css b/chrome_point_plus/css/point-plus.css index 712f4b9..7f18dc2 100644 --- a/chrome_point_plus/css/point-plus.css +++ b/chrome_point_plus/css/point-plus.css @@ -163,34 +163,4 @@ div#markItUpText-input { #comments .post:hover .nesting { background-repeat: repeat-x; 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'); - } } \ No newline at end of file diff --git a/chrome_point_plus/js/point-plus.js b/chrome_point_plus/js/point-plus.js index aba2d9d..a76262b 100644 --- a/chrome_point_plus/js/point-plus.js +++ b/chrome_point_plus/js/point-plus.js @@ -156,6 +156,11 @@ $(document).ready(function() { type: 'injectCSSFile', file: 'vendor/fancybox/source/jquery.fancybox.css' }); + // @todo message response callback processing + chrome.runtime.sendMessage({ + type: 'injectCSSFile', + file: 'css/fancybox/style.css' + }); // JS chrome.runtime.sendMessage(null, { type: 'executeJSFiles', diff --git a/chrome_point_plus/manifest.json b/chrome_point_plus/manifest.json index a303791..8ddd8dd 100644 --- a/chrome_point_plus/manifest.json +++ b/chrome_point_plus/manifest.json @@ -44,6 +44,7 @@ "web_accessible_resources": [ "images/*", "includes/*", + "vendor/*", "manifest.json" ], "background": { From c0e18f8807e7e0fc24fcb64d5c2a7d44c154b7fe Mon Sep 17 00:00:00 2001 From: Alexey Skobkin Date: Wed, 7 Jan 2015 09:51:51 +0400 Subject: [PATCH 6/8] Small fixes. --- chrome_point_plus/js/background.js | 2 +- chrome_point_plus/js/point-plus.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/chrome_point_plus/js/background.js b/chrome_point_plus/js/background.js index d4fe28d..8beb756 100644 --- a/chrome_point_plus/js/background.js +++ b/chrome_point_plus/js/background.js @@ -13,7 +13,7 @@ chrome.storage.sync.get('options_version', function(data) { * Inject several JS files * @param {number} tabId Unique ID of tab which requested injection * @param {Object[]} files Array of objects of files to inject - * @callback onAllInjected Callback function running when injection ends + * @param {function} onAllInjected allback function running when injection ends */ function injectJS(tabId, files, onAllInjected) { var item = files.shift(); diff --git a/chrome_point_plus/js/point-plus.js b/chrome_point_plus/js/point-plus.js index a76262b..7b49e79 100644 --- a/chrome_point_plus/js/point-plus.js +++ b/chrome_point_plus/js/point-plus.js @@ -176,7 +176,7 @@ $(document).ready(function() { // If all JS are executed console.debug('Fancybox injection response: %O', response); if (response) { - console.log('Fancybox executed. Processing...') + console.log('Fancybox executed. Processing...'); if (options.is('option_fancybox_bind_images_to_one_flow')) { // Linking images in posts to the galleries @@ -396,7 +396,7 @@ $(document).ready(function() { try { // ping :) if (evt.data == 'ping') { - console.debug('ws-ping'); + console.info('ws-ping'); } else { var wsMessage = JSON.parse(evt.data); @@ -634,7 +634,7 @@ $(document).ready(function() { }); function getProtocol() { - return ((location.protocol == 'http:') ? 'http:' : 'https:') + return ((location.protocol == 'http:') ? 'http:' : 'https:'); } function escapeHtml(text) { From e8bbd4dc36d7f89e7400220e6ca7126da83f4232 Mon Sep 17 00:00:00 2001 From: Alexey Skobkin Date: Wed, 7 Jan 2015 20:10:29 +0400 Subject: [PATCH 7/8] Corrections. --- chrome_point_plus/css/fancybox/style.css | 34 ++----------------- .../css/markitup/skins/markitup/style.css | 16 ++++----- 2 files changed, 10 insertions(+), 40 deletions(-) diff --git a/chrome_point_plus/css/fancybox/style.css b/chrome_point_plus/css/fancybox/style.css index e6931de..2de2c9e 100644 --- a/chrome_point_plus/css/fancybox/style.css +++ b/chrome_point_plus/css/fancybox/style.css @@ -9,14 +9,11 @@ } #fancybox-loading div { - background: url('chrome-extension://__MSG_@@extension_id__/vendor/fancybox/source/fancybox_loading.gif') center center no-repeat; + background-image: url('chrome-extension://__MSG_@@extension_id__/vendor/fancybox/source/fancybox_loading.gif'); } -.fancybox-nav { - background: transparent url('chrome-extension://__MSG_@@extension_id__/vendor/fancybox/source/blank.gif'); /* helps IE */ -} .fancybox-overlay { - background: url('chrome-extension://__MSG_@@extension_id__/vendor/fancybox/source/fancybox_overlay.png'); + background-image: url('chrome-extension://__MSG_@@extension_id__/vendor/fancybox/source/fancybox_overlay.png'); } @media only screen and (-webkit-min-device-pixel-ratio: 1.5), @@ -30,31 +27,4 @@ only screen and (min-device-pixel-ratio: 1.5) { #fancybox-loading div { background-image: url('chrome-extension://__MSG_@@extension_id__/vendor/fancybox/source/fancybox_loading@2x.gif'); } -}/* 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/blank.gif'); /* helps IE */ -} -.fancybox-overlay { - background: url('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/fancybox_sprite@2x.png'); - } - - #fancybox-loading div { - background-image: url('chrome-extension://__MSG_@@extension_id__/vendor/fancybox/source/fancybox_loading@2x.gif'); - } -} \ No newline at end of file diff --git a/chrome_point_plus/css/markitup/skins/markitup/style.css b/chrome_point_plus/css/markitup/skins/markitup/style.css index 630a175..2eaf26e 100644 --- a/chrome_point_plus/css/markitup/skins/markitup/style.css +++ b/chrome_point_plus/css/markitup/skins/markitup/style.css @@ -1,5 +1,5 @@ .markItUpContainer { - background:#FFF url(chrome-extension://__MSG_@@extension_id__/images/markitup/skins/markitup/bg-container.png) repeat-x top left; + background-image: url(chrome-extension://__MSG_@@extension_id__/images/markitup/skins/markitup/bg-container.png); } .markItUpEditor { background: none; @@ -12,25 +12,25 @@ /***************************************************************************************/ /* first row of buttons */ .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); } .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); } /***************************************************************************************/ .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 { - 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 { - 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 { - 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, .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); } \ No newline at end of file From 3c66c1fbb57b43ddf87a3028aaf12e5d81bd21fa Mon Sep 17 00:00:00 2001 From: Alexey Skobkin Date: Wed, 7 Jan 2015 20:14:42 +0400 Subject: [PATCH 8/8] Drop prefixes. --- chrome_point_plus/css/fancybox/style.css | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/chrome_point_plus/css/fancybox/style.css b/chrome_point_plus/css/fancybox/style.css index 2de2c9e..10c7f5e 100644 --- a/chrome_point_plus/css/fancybox/style.css +++ b/chrome_point_plus/css/fancybox/style.css @@ -16,10 +16,7 @@ background-image: url('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) { - +@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'); }