Chrome inline installation works only half of the time -
we've set simple inline webstore installer our app.
the app site has been verified. inline installation work correctly half of inside our company, doesn't work other half. "uncaught typeerror: cannot call method 'install' of undefined testsupport.html:15 uncaught syntaxerror: unexpected token ). it's though chrome or chrome.web variable isn't initialized.
why inline installation work on machines not on others? these machines have same chrome browser version.
tia
i've not seen issue before try provide breakdown of setup use manage inline installations multiple chrome extensions on my website.
within head node of every page (optionally, pages may include 1 or more install links) add required links each extension/app page on chrome web store. allows me add install links anywhere on page various extensions/apps. javascript binds event handler each of install links once dom has finished loading. event handler's sole purpose install extension/app links when clicked , change state prevent further install attempts.
<!doctype html> <html> <head> ... <!-- link each extension/app page --> <link rel="chrome-webstore-item" href="https://chrome.google.com/webstore/detail/dcjnfaoifoefmnbhhlbppaebgnccfddf"> <script> // ensure dom has loaded document.addeventlistener('domcontentloaded', function() { // support other browsers var chrome = window.chrome || {}; if (chrome.app && chrome.webstore) { // fetch install links var links = document.queryselectorall('.js-chrome-install'); // create "click" event listener var onclick = function(e) { var = this; // attempt install extension/app chrome.webstore.install(that.href, function() { // change state of button that.innerhtml = 'installed'; that.classlist.remove('js-chrome-install'); // prevent further clicks attempting install that.removeeventlistener('click', onclick); }); // prevent opening of web store page e.preventdefault(); }; // bind "click" event listener links (var = 0; < links.length; i++) { links[i].addeventlistener('click', onclick); } } }); </script> ... </head> <body> ... <!-- allow inline installation links identified --> <a href="https://chrome.google.com/webstore/detail/dcjnfaoifoefmnbhhlbppaebgnccfddf" class="js-chrome-install">install</a> ... </body> </html> in order system work need support scenarios user has returned website after installing extension/app. although official documentation suggests using chrome.app.isinstalled doesn't work when multiple extensions/apps can installed single page. around issue can add content script extension/app following install.js file;
// fetch install links extension/app running var links = document.queryselectorall('.js-chrome-install[href$=dcjnfaoifoefmnbhhlbppaebgnccfddf]'); // change state of links (var = 0; < links.length; i++) { links[i].innerhtml = 'installed'; // website script no longer bind "click" event listener executed first links[i].classlist.remove('js-chrome-install'); } then need modify manifest.json file ensure content script executed on domain.
{ ... "content_scripts": [ { "js": ["install.js"], "matches": ["*://*.yourdomain.com/*"], "run_at": "document_end" } ] ... } this result in content script being run before javascript on website there no install links js-chrome-install class time executed, no event handlers bound etc.
below example of how use system;
homepage: http://neocotic.com
project homepage: http://neocotic.com/template
project source code: https://github.com/neocotic/template
Comments
Post a Comment