diff --git a/extension/writing-process/src/inject.js b/extension/writing-process/src/inject.js deleted file mode 100644 index 613429ba3..000000000 --- a/extension/writing-process/src/inject.js +++ /dev/null @@ -1,19 +0,0 @@ -/* - Inject script. This is a web_accessible_resources used to pass the id - of the document as a globally accessible variable to the extension. - It is called by the injectScript function in writing.js to make the result - accessible using an event listener. - - TODO: - * We don't really understand this code. It should be commented - * In particular, why are we using an IIFE (immediately invoked function - expression) rather than just the code? - - If this is a relic, it should be cleaned up. If this has a - reason, it should be documented. -*/ - -(function() { - const result = JSON.stringify(_docs_flag_initialData.info_params.token); - window.postMessage({ from: 'inject.js', data: result }); -})(); diff --git a/extension/writing-process/src/manifest.json b/extension/writing-process/src/manifest.json index 9d26efaa6..f663bf58f 100644 --- a/extension/writing-process/src/manifest.json +++ b/extension/writing-process/src/manifest.json @@ -36,11 +36,6 @@ "matches": ["*://docs.google.com/document/*"], "js": ["3rdparty/sha256.js", "writing_common.js", "writing.js"] }], - "web_accessible_resources": [{ - "resources": ["inject.js"], - "matches": ["*://docs.google.com/*"], - "use_dynamic_url": true - }], "host_permissions": [ "*://docs.google.com/document/*" ], diff --git a/extension/writing-process/src/writing.js b/extension/writing-process/src/writing.js index 1367e8a81..f318f404d 100644 --- a/extension/writing-process/src/writing.js +++ b/extension/writing-process/src/writing.js @@ -3,7 +3,7 @@ */ /* For debugging purposes: we know the extension is active */ -document.body.style.border = "5px solid blue"; +// document.body.style.border = "1px solid blue"; import { googledocs_id_from_url, treeget } from './writing_common'; /* @@ -142,29 +142,31 @@ function is_string(myVar) { } } -function injectScript(file_path, tag) { - /* - This function is to inject a script from 'file_path' - into a specific DOM tag passed in as 'tag' - */ - var node = document.getElementsByTagName(tag)[0]; - var script = document.createElement('script'); - script.setAttribute('type', 'text/javascript'); - script.setAttribute('src', file_path); - node.appendChild(script); -} - -function execute_on_page_space(code){ - /* This is from - https://stackoverflow.com/questions/9602022/chrome-extension-retrieving-global-variable-from-webpage - - It is used to run code outside of the extension isolation box, - for example to access page JavaScript variables. +function extractDocsToken() { + /** + * We need the doc token to be able to fetch the document + * history. This token is provided via a