Remove URL from extension - google-chrome-extension

I built a new chrome extension and want to remove\hide the URL (chrome-extension://id/).
Any idea how to remove it?
I already tried to do that with History.API and chrome.omnibox

Related

Specifying path/filename in downloads.download() api not working in Chrome but does in Firefox

Specifying path/filename to downloading file does not work in chrome.downloads api but does work for firefox browser.downloads api.
I have a very simple call in popup.js for chrome and firefox:
chrome.downloads.download({url: address, filename: path + "/" + filename, saveAs: false});
Here's another one for Firefox:
browser.downloads.download({url: addresss, filename: path + "/" + filename, saveAs: false});
It works perfectly as expected in firefox, but no matter what, I can't ever get it to work in chrome. Even with a simple download of google's image to a different file name never works chrome but does in firefox, such as:
chrome.downloads.download({url: "https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png", filname: "temp/temp.png"});
What am I doing wrong?
It's been awhile but I'll post my solution for whoever comes across this issue for their extension. It turns out that specifying a custom filename isn't working is because there are extension conflicts.
If there is another extension using the chrome.downloads API, specifically the chrome.downloads.onDeterminingFilename.addListener, which tries to specify the filename that overrides the original filename suggestion. This also happens even if the conflicting extension did not change your download options but just added a listener for onDeterminingFilename without doing any logic. This is a known chromium issue here: https://bugs.chromium.org/p/chromium/issues/detail?id=579563. That issue has been opened since 2016 and the devs still have not addressed it.
Workaround solution: implement your own chrome.downloads.onDeterminingFilename.addListener to suggest your custom filename. Make sure that you're only capturing downloads that you started yourself but comparing the download item's id and extension id. The only caveat is that the conflicting extension will produce an error saying they could not suggest their own filename.
Firefox does not have this issue because their extension API does not have onDeterminingFilename.

After deletion of chrome extension remove some html elements from website

Hi I am new to chrome extension. I have build the basic chrome extension and I want to install it using inline installation. I followed the following link :
https://developer.chrome.com/webstore/inline_installation#already-installed
All is working properly. I want to check if extension is already installed or not so I referred the above document, whenever user install the extension at that time we are appending the new div using content script to my installation page on website. If that div is present it means the extension is already installed.
Following code is added in my content_script of chrome extension for appending the div whenever the extension is installed:
var isInstalledNode = document.createElement('div');
isInstalledNode.id = 'extension-is-installed';
document.body.appendChild(isInstalledNode);
Then my installation page can check for the presence of that DOM node, which signals that the extension is already installed:
if (document.getElementById('extension-is-installed')) {
document.getElementById('install-button').style.display = 'none';
}
But I am facing one problem, whenever I deleted my extension from settings/extensions, still the div is present on extension's installation page.
Is their any provision to remove the div when my extension is deleted or removed from browser?
You can't catch the uninstallation event for your own extension, though there is an management.onUninstalled, it is used for listening to other extensions/apps. See following answer for more details:
How to listen to uninstallation event in javascript from a chrome extension?
I just come up with two workarounds, one is creating another extension to listen to the uninstall of your first extension; another one is using runtime.setUninstallURL to visit a URL upon uninstallation, you can do something in server if you want.
BTW, for isInstalledNode, you needn't/shouldn't set the id, since there may be other elements in the webpage with the same id, you just need to create the node and use document.body.contains(isIntalledNode) to check if it exists.

What is wrong with this chrome extension?

I have downloaded this chrome extension https://github.com/jeffreyiacono/penalty-blox
When I load it via load unpacked extension it gives me this error
1.manifest_version key must be present and set to 2
I solved it via adding manifest_version in manifest.json
2.After this when I reload it,The icon is coming but when I click on it nothing is working(looks like background.html is not working)
What changes should I do so that it workes perfectly?

firefox addon: download external url into string

I need to download some external urls to a string in a firefox addon.
How can I access the content of external urls for parsing?
To find out the url of the current tab in a firefox addon you can do:
var localString = gBrowser.currentURI.spec;
Then you can parse localString the way you want.

Google Chrome Extension Adding iframe from source

I'm trying to load myframe.html inside an iframe and attach that iframe to the DOM of the current page. Is this possible, if myframe.html is part of my extension source?
I was thinking something like
var iframe = document.createElement("iframe");
iframe.setAttribute("src", "myframe.html"); //what would be my path here, if this were possible?
document.body.appendChild(iframe);
It should be possible, use a content script to inject javascript into the page and then use the chrome.extension.getURL() method to get the correct URL to your file hosted inside your extension

Resources