Access variables and functions defined in page context from an extension

Underlying cause: A content script is executed in an ISOLATED “world” environment, meaning it can’t access JS functions and variables in the MAIN “world” (the page context), and can’t expose its own JS stuff, like the state() method in your case. Solution: Inject the code into the JS context of the page (MAIN “world”) using … Read more

Chrome Extension Writing to Google Spreadsheet [closed]

Yes, it is definitely possible. I have used the Spreadsheet API extensively using Javascript. You’ll need to use the Protocol version of the API as documented here: https://developers.google.com/google-apps/spreadsheets/ This requires sending signed requests using OAuth2 (the older auth protocols aren’t really reliable anymore.) so I suggest using an OAuth2 library like JSO. https://github.com/andreassolberg/jso When writing … Read more

Content Security Policy: cannot load Google API in Chrome extension

I wrestled with this issue for the past 12 hours and finally got it to work. Why did it take so long? Because I got thrown off the trail multiple times. First, the false leads: “Make it HTTPS” — Doesn’t matter. My Chrome extension now makes regular HTTP calls to a different domain and works … Read more

Adding complex HTML using a Chrome content script

It’s relatively easy to add whole web pages by having your content script inject them in an iframe. Just follow these guidelines: Place the *.htm or *.html files in your extension’s source folder(s). Place any *.css and *.js files, that the HTML uses, in the extension folder(s) too. Declare the HTML file(s) as resources. EG: … Read more

Injecting multiple scripts through executeScript in Google Chrome

This is my proposed solution: function executeScripts(tabId, injectDetailsArray) { function createCallback(tabId, injectDetails, innerCallback) { return function () { chrome.tabs.executeScript(tabId, injectDetails, innerCallback); }; } var callback = null; for (var i = injectDetailsArray.length – 1; i >= 0; –i) callback = createCallback(tabId, injectDetailsArray[i], callback); if (callback !== null) callback(); // execute outermost function } Subsequently, the … Read more

How to remove event listener in Chrome extension

removeListener takes an argument. You need to name the listener function and then remove it by name: function doStuff(request){ chrome.extension.onRequest.removeListener(doStuff); other_function(request); } chrome.extension.onRequest.addListener(doStuff); Or, more succinctly: chrome.extension.onRequest.addListener( function doStuff(request){ chrome.extension.onRequest.removeListener(doStuff); other_function(request); } );

Apps, Extensions and scripts cannot be added from this website

Instead of opening the file, you have to: extract it (crx are zip files), then visit chrome://extensions, enable developer mode, and load unpacked extension. The reason for this is: lots of people try to abuse chrome apps/extensions to install nasty applications to your browser. So Chrome tries to make it impossible to automatically side-load these … Read more

Chrome – Debug Angular/Typescript – how to navigate to ts file

Angular uses webpack and all type script files are listed under it. To select your target typescript file, Chrome’s Developer tool (F12). Go to Source tab, Select Chrome “webpack://”->”src/app” -> your typescript file. Or in older version of chrome follow this path “webpack://”->”.”->”src/app” -> your typescript file ( See the image file). Or Ctrl+P to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)