diff --git a/manifest.json b/manifest.json index 85c3e03..c1e4dcf 100644 --- a/manifest.json +++ b/manifest.json @@ -10,7 +10,7 @@ "128": "img/JustNotSorry-128.png" }, "content_scripts": [ { - "matches": ["https://mail.google.com/*"], + "matches": ["https://mail.google.com/*", "https://inbox.google.com/*"], "css": ["just-not-sorry.css"], "js": ["lib/head.load.min.js", "src/ScriptLoader.js"] } diff --git a/src/JustNotSorry.js b/src/JustNotSorry.js index 0e9a9e2..1a9a762 100644 --- a/src/JustNotSorry.js +++ b/src/JustNotSorry.js @@ -15,6 +15,32 @@ var JustNotSorry = function() { var gmail; var warningChecker; + function observeContentEditable() { + console.log('observeContentEditable'); + var observer = new MutationObserver(function(mutations) { + console.log('in mutation observer'); + mutations.forEach(function(mutation) { + //var changedNode = mutation.target; + var myNodeList = mutation.addedNodes; + for (var i = 0; i < myNodeList.length; ++i) { + var node = myNodeList[i]; + if (node.querySelectorAll) { + var editableNodes = node.querySelectorAll('div[contentEditable=true]'); + if (editableNodes.length > 0) { + console.log('mutation', mutation); + console.log('node ' + i, node); + console.log(editableNodes); + } + } + //if (node.getAttribute('contentEditable')) { + // console.log('node ' + i, myNodeList[i]); + //} + } + }); + }); + observer.observe(document, {childList: true, subtree: true}); + } + function addWarningsOnFocusIn(compose) { var $target = compose.$el; $target.focusin(function(e) { @@ -54,9 +80,11 @@ var JustNotSorry = function() { updateWarningsOnMutation(compose); } - gmail = new Gmail(); + //gmail = new Gmail(); warningChecker = new WarningChecker(WARNINGS); - gmail.observe.on('compose', checkForWarnings); + //gmail.observe.on('compose', checkForWarnings); + observeContentEditable(); }; -refresh(JustNotSorry); +JustNotSorry(); +//refresh(JustNotSorry);