How can is check chrome extension is installed or not , when extension is disabled ?
I found that when extension is disabled we can not access the background.js and also its icon.png or manifest.json.
While the extension is disabled, both the background script and the content script are alive, but the communication medium is disabled. So you can't send messages between them.
Can be captured using
chrome.runtime.connect().onDisconnect.addListener(function(e) {});
In the worst case, you can do a POST message.
If a extension is disabled, any code in it would not work, so it is not possible to get the installation status from a disabled extension
You can capture using
chrome.runtime.connect().onDisconnect.addListener(function(e) {
...
});
Related
I have stored a colour value in my firefox extension using this code
function saveOptions(e) {
browser.storage.sync.set({
colour: document.querySelector("#colour").value
});
e.preventDefault();
}
This works fine but to retest the extension I want to completely remove all the data previously set by the extension and then wants to freshly test the extension.How can we remove stored values in firefox extension?
EDIT:
I am following this project and delete All using inspect>Storage>Extension Storage does not work.
In Firefox you can put in about:debugging in the URL which will bring up the list of addons you have installed. If you inspect the addon you'll see an option to view the Extension Storage. You can "delete all" from there.
Try using browser.storage.sync.clear()
I am developing wallet to pay for e-commerce websites.
I need to add a check on the JS page if the user has installed chrome extension ( iwallet ) or not.
As said in a previous answer you can't do that. That's because if such a thing was actually present it will be a privacy issue for the chrome users.
Actually the chrome web store is the only website that has access to such a chrome api.
BUT - looking at the source code of the extension you can check what the extension is altering in you browser or even which messages its listening to.
In the Iwallet source code I found in content-script.js and inpage.js that it sets a special window object property window.IWalletJS and you can simply check if it exist to determine if the extension is installed or not.
As simple as:
if('IWalletJS' in window){
console.log("IWallet is installed", window.IWalletJS);
} else {
console.log("IWallet is not installed");
}
Take a look at the object attached to this property you can check if the user is logged, account name and more.
Is it possible to launch a Google Chrome extension within a website? E.g run some javascript that will launch the extensions UI?
I'm building a web-app that will allow users to take screenshots of their desktop and edit them. I've got a sample extension up and running using dektopCapture but it is an 'app' style of an extension.
It allows to select a window to stream from, then take a
snapshot within the extension UI(using a button) that is saved as an image string
My question is:
Is it possible to fire up the desktopCapture UI (the window that gets the available windows to stream from), from within my web-app, maybe a button, take the stream and place it on a canvas/HTML5 video element within my web-app?
I'm figuring that I could hook-up an event-listener within the extension and use runtime.onMessage to post a message from within my app
Notes:
If there's a more intuitive way to do this, I can go that route - e.g If I could keep as much interaction within the web-app with just the extension running in the background, that would be even better.
The extension is of type browser_action but I want it to be applicable to a single page(the app's webpage) so if it can be used in a page_action I'd prefer that instead. There's really no need to have browser_action icon if I can trigger this from within a webpage
I'm also planning to build a FF extension so any insights there are also appreciated.
So I'm answering my own question.
I've managed to get it working using externally_connectables.
The externally_connectable manifest property declares which
extensions, apps, and web pages can connect to your extension via
runtime.connect and runtime.sendMessage.
1. Declare app/webpage in manifest.json
Just declare your web-app/page within your manifest.json as an externally_connectable.
E.g I wanted to connect my app is hosted on Github Pages and I have a domain name of https://nicholaswmin.github.io, so it does a bit like this:
"externally_connectable": {
"matches": ["https://nicholaswmin.github.io/*"]
}, //rest of manifest.json
2. Set up event listener for messages in background.js
Then set up an event listener in your background.js like so:
chrome.runtime.onMessageExternal.addListener(function(request, sender, sendResponse) {
//Stuff you want to run goes here, even desktopCapture calls
});
3. Send message from your web/app page
And call it from within your web-app/website like this:
chrome.runtime.sendMessage("APP ID GOES HERE",
{data: { key : "capture"}});
Make sure that your website is correctly declared as an externally_connectable in your manifest.json and that you are passing the app-id when sending the message
The main idea is to run a random page on Internet Explorer and get javascript errors and logs.
Is there a way to recover javascript console logs and execution error
from a random web page without accessing the F12 tool on Internet
Explorer?
I found that with Chrome based browser, you can get it on your AppData file log by adding --enable-logging --v=1 args when launching.
Any solution with any language are welcome.
Thank you for your answer.
NOTE :
random page on Internet Explorer means that I do not have the access on the source code.
Basic solution to this would be:
1. Use Exception Handling to catch the errors.
2. Log errors in a Global Array
3. Log the errors in a file using Blob and URL.createObjectURL. All recent browsers support this.
Have you considered using a Bookmarklet that:
Overrides window.console.log and window.console.error (to intercept messages)
Logs incoming messages somewhere using createObjectURL?
Or you could use something like firebuglite and auto-enable it like this:
<script type="text/javascript" src="https://getfirebug.com/firebug-lite.js">
{
overrideConsole: false,
startInNewWindow: true,
startOpened: true,
enableTrace: true
}
</script>
More instructions are here: http://getfirebug.com/firebuglite
If the F12 tool is not of your interest, then what about the Event Viewer? Open Event Viewer from Control Panel -> System and Security -> Administrative Tools -> Event Viewer. Then select the log Applications and Services Logs\Internet Explorer.
By default no events are being logged for Internet Explorer, to enable them create a new DWORD registry value named Feature_Enable_Compat_Logging under the following registry key:
HKCU\SOFTWARE\Microsoft\Windows\Internet Explorer\Main \FeatureControl
and set the registry value to 1.
Check the logs you get to see if it's what you're looking for.
One idea would be to write a browser extension which listens for window.onerror and writes to a file. Definitely not as elegant as the Chrome solution, but it would work fairly well.
Using local proxy might be a good one-time solution.
Charles web debugging proxy app has nice UI and it allows to replace any response with local resource.
So basically you'll need:
Download one any of the js files used on target page
add any code you wish to saved version
set up Charles to serve you your local version instead of remote one
You might try Fiddler. It's got its own logging and has amazing inspection power. It won't capture IE specific errors, since it's at a different layer, but it will definitely get you any code that's coming over the wire.
I wrote my small extension for Chrome which works in the context of the webpage.
Everything is fine, except that code is executed every time when I visit URL defined in the manifest.json in content-scripts matches.
What I would like is to launch it manually - 'on demand' - after clicking on the icon of the extension next to the url bar.
Is this possible?
Yes - it is possible.
I've took it from: http://developer.chrome.com/extensions/content_scripts.html
The relevant part is:
"...To insert code into a page, your extension must have cross-origin permissions for the page. It also must be able to use the chrome.tabs module. You can get both kinds of permission using the manifest file's permissions field. Once you have permissions set up, you can inject JavaScript into a page by calling executeScript()..."
/* in background.html */
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.executeScript(null,
{code:"document.body.bgColor='red'"});
});