From d00345f45b5b3e56970237799c69808527e91919 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sat, 1 Oct 2016 12:05:29 +0100 Subject: Use HTML5 import to load content scripts. This is one approach to fixing #2277 properly. (Currently there's a temporary fix in place.) This uses HTML5 imports in place of the content-script loader. This is better than the current "fix" because content scripts are only listed in one place two places (as opposed to six). It's worse than the previous content-script loader, though, in that content scripts must be listed in two places, instead of one. Fixes #2277. --- manifest.json | 2 ++ pages/blank.html | 25 +------------------------ pages/completion_engines.html | 25 +------------------------ pages/content_script_loader.coffee | 28 ---------------------------- pages/help_dialog.html | 25 +------------------------ pages/logging.html | 25 +------------------------ pages/options.html | 25 +------------------------ pages/vimium_resources.html | 24 ++++++++++++++++++++++++ 8 files changed, 31 insertions(+), 148 deletions(-) delete mode 100644 pages/content_script_loader.coffee create mode 100644 pages/vimium_resources.html diff --git a/manifest.json b/manifest.json index d95ca9f6..a40cd134 100644 --- a/manifest.json +++ b/manifest.json @@ -35,6 +35,8 @@ ], "content_scripts": [ { + "_comment": + "IMPORTANT: All resources listed here must also be listed in ./pages/vimium_resources.html.", "matches": [""], "js": ["lib/utils.js", "lib/keyboard_utils.js", diff --git a/pages/blank.html b/pages/blank.html index 4f0d7bfa..c238282d 100644 --- a/pages/blank.html +++ b/pages/blank.html @@ -1,30 +1,7 @@ New Tab - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/pages/completion_engines.html b/pages/completion_engines.html index 114dc0db..d47bb87b 100644 --- a/pages/completion_engines.html +++ b/pages/completion_engines.html @@ -4,30 +4,7 @@ - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/pages/content_script_loader.coffee b/pages/content_script_loader.coffee deleted file mode 100644 index 5058bb7b..00000000 --- a/pages/content_script_loader.coffee +++ /dev/null @@ -1,28 +0,0 @@ -injectContentScripts = -> - manifest = chrome.runtime.getManifest() - content_scripts = manifest.content_scripts - - insertLocation = document.head.firstChild - - for scriptInfo in content_scripts - continue if scriptInfo.matches.indexOf("") == -1 - - if scriptInfo.js - for script in scriptInfo.js - scriptElement = document.createElement "script" - scriptElement.type = "text/javascript" - scriptElement.async = false # Don't load out of order! - scriptElement.src = chrome.runtime.getURL script - - insertLocation.parentElement.insertBefore scriptElement, insertLocation - - if scriptInfo.css - for style in scriptInfo.css - styleElement = document.createElement "link" - styleElement.rel = "stylesheet" - styleElement.type = "text/css" - styleElement.href = chrome.runtime.getURL style - - insertLocation.parentElement.insertBefore styleElement, insertLocation - -injectContentScripts() diff --git a/pages/help_dialog.html b/pages/help_dialog.html index 1e7fdd80..c23b2ac1 100644 --- a/pages/help_dialog.html +++ b/pages/help_dialog.html @@ -1,30 +1,7 @@ Vimium Help - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/pages/logging.html b/pages/logging.html index dd05e819..bc4ffb80 100644 --- a/pages/logging.html +++ b/pages/logging.html @@ -1,30 +1,7 @@ Vimium Logging - - - - - - - - - - - - - - - - - - - - - - - +