javascript - Chrome Extension only hitting my main.js upon page reload -
i creating chrome extension trello which, @ basic start, adds button top of trello header.
i following code:
manifest.json { "name": "trello item linker", "version": "1", "manifest_version" : 2, "description": "creates links every item number referenced in trello card.", "background" : { "page" : "background.html", "persistent": false }, "page_action" : { "default_icon": { "19": "icons/19.png", "38": "icons/38.png" } }, "content_scripts": [ { "matches": ["https://trello.com/b/*"], "js": [ "lib/jquery-2.1.1.min.js", "scripts/main.js" ], "run_at": "document_idle" } ], "permissions": [ "tabs" ], "icons": { "16": "icons/16.png", "48": "icons/48.png", "128": "icons/128.png" }, "web_accessible_resources": [ "settings/index.html" ], "options_page": "settings/index.html" }
in main.js script, have following snippet:
chrome.extension.sendmessage({}, function (response) { var readystatecheckinterval = setinterval(function () { if (document.readystate === "complete") { console.log(">document ready"); clearinterval(readystatecheckinterval); if($(".header-user").html().includes("create item links")){ console.log(">header contains item option"); } else{ $(".header-user").append('<a class="header-btn js-linkscrs" href="#">link scrs</a>'); console.log(">create item links added header"); } clearinterval(readystatecheckinterval); } else{ console.log("document not ready"); } $(".js-linkscrs").click(function(e){ linkitems(event); }); }, 10); }); /**
whenever navigate trello.com/b/* page (by using trello board links), document.readystate never being set complete. therefore, button not being inserted. when refresh entire page, document.readystate set complete, , rest of code fires expected. missing?
this first chrome extension hoping learning experience me first , foremost.
thanks!
Comments
Post a Comment