Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions contributors/dcoles.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
2018-11-13

I hereby agree to the terms of the "Markdown Here Individual Contributor License
Agreement", with MD5 checksum 6a31e08cf66139e91c0db5599b6ab084.

I furthermore declare that I am authorized and able to make this agreement and
sign this declaration.

Signed,

David Coles https://github.com/dcoles
36 changes: 34 additions & 2 deletions src/chrome/backgroundscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,42 @@ function upgradeCheck() {
});
}

// Load content script dependencies.
function loadContentScripts(done) {
chrome.tabs.executeScript(
{code: 'document.markdown_here_loaded'}, function(results) {
if (results[0]) {
done();
return;
}

let srcs = [
"common/utils.js",
"common/common-logic.js",
"common/jsHtmlToText.js",
"common/marked.js",
"common/mdh-html-to-text.js",
"common/markdown-here.js",
"chrome/contentscript.js"
];

for (let i=0; i<srcs.length; i++) {
chrome.tabs.executeScript({file: srcs[i]});
}

chrome.tabs.executeScript(
{code: 'document.markdown_here_loaded = true'}, done);
});
}

// Create the context menu that will signal our main code.
chrome.contextMenus.create({
contexts: ['editable'],
title: Utils.getMessage('context_menu_item'),
onclick: function(info, tab) {
chrome.tabs.sendMessage(tab.id, {action: 'context-click'});
loadContentScripts(function() {
chrome.tabs.sendMessage(tab.id, {action: 'context-click'});
});
}
});

Expand Down Expand Up @@ -149,7 +179,9 @@ chrome.runtime.onMessage.addListener(function(request, sender, responseCallback)

// Add the browserAction (the button in the browser toolbar) listener.
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.sendMessage(tab.id, {action: 'button-click', });
loadContentScripts(function() {
chrome.tabs.sendMessage(tab.id, {action: 'button-click', });
});
});


Expand Down
16 changes: 1 addition & 15 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,8 @@
"128": "common/images/icon128.png",
"512": "common/images/icon512.png"
},
"permissions": ["contextMenus", "storage"],
"permissions": ["contextMenus", "storage", "activeTab"],
"background": {"page": "chrome/background.html"},
"content_scripts": [
{
"matches": ["http://*/*", "https://*/*"],
"js": [
"common/utils.js",
"common/common-logic.js",
"common/jsHtmlToText.js",
"common/marked.js",
"common/mdh-html-to-text.js",
"common/markdown-here.js",
"chrome/contentscript.js"
]
}
],
"browser_action": {
"default_icon": {
"16": "common/images/icon16-button-monochrome.png",
Expand Down