Action when chrome extension closing - google-chrome

I've a chrome extension wich open a new tab and inject any javascript into it.
But whenever that the extension is reloaded, it open again a new tab.
So, i want close the tabs when my extension is closed/disabled.
There is chrome.management.onDisabled, but this don't working for this extension, but for other extension. But ... perhaps the code which is injected in the tab can detect if extension is Closed ? For example, if the extension could send a message (with tab.sendMessage) when it is closing ...
Any suggestion or idea ?
Thank you very much, and excuse me for my bad english.

Related

Chrome: Bookmark / Bookmarklet to open a URL with clipboard-Content

Is there a way to dynamically include clipboard content into a URL of a Bookmark / Bookmarklet in Chrome?
For example, i copy a story number ("test-1234") and want to open it in jira, it would be helpful i could just click the bookmark, something like this:
https://jira.mydomain.com/browse/{clipboardContent}
and it would open the URL:
https://jira.mydomain.com/browse/test-1234
Or is there a chrome-extension that would make it possible?
With chrome.contexMenu API you can select any text ("test-1234") from any web page
and activate a function (present in the contextual menu)
that opens a new tab (or window) with an URL constructed by the fixed part and the parameter in the queue.
You have to grant "contextMenu" and "activeTab" in your manifest.
For further details please read: https://developer.chrome.com/docs/extensions/reference/contextMenus/
I'm doing since years exactly what you've described, but I'm on MacOS and for this I'm using Alfred App (https://www.alfredapp.com). I've created an own Workflow for this. If you're on WIN, then there is something which could be similar to Alfred App --> https://github.com/Wox-launcher/Wox

How to add custom message in chrome infobar?

I used to think that this was not possible but I recently saw that Testim has an extension that does this.
Core aim: Add a message in the page which doesn't interfere with the DOM/CSS of the existing page.
Chrome/Chromium injects "The browser is being automated" message in the page when the browser is run from puppeteer. But as I understood, this isn't an editable message. How is testim able to do this?
Here's a screenshot showing exact message:
This is the message that is shown, when an Chrome extension attaches to a tab via the chrome.debugger API. It shows the name of the extension which is attached to the page, in your case the Testim Editor extension.
Removing the infobar
To remove that bar, you have can either enable the "Silent Debugging" option in the Chrome flags (chrome://flags) manually or use the --silent-debugger-extension-api flag when starting Chrome. There is no way to disable it programmatically from inside your extension.

Is there a way to stop Google Chrome from showing most visited sites on a blank tab?

Whenever I open a new tab in Google Chrome I see the Google search bar plus 8 thumbnails of recently visited (or most visited) sites. I never click on the thumbnails and find them to be annoying. Is there anyway to disable this in Chrome?
I can think of a hacky workaround like creating a blank page someplace and setting that to be the new tab page, but there must be a better way. Any ideas?
Since nobody answered I thought I would post and answer to my question:
Use the Empty New Tab Page extension for a new blank tab instead of the default new tab.
There are also some redirect extensions such as Momentum, which loads a different full screen image each day.
type chrome://flags then Disable "Top Sites from Site Engagement"
Chrome allows extensions to run on chrome:// urls so one such possible future solution is if AdBlock explicitly requests the permission to run on chrome://newtab then you can just block the div with id most-visited. But currently AdBlock does not request this permission.
You could edit the manifest of AdBlock manually to include this permission or suggest it as a future feature.
The default new tap page's url is chrome-search://local-ntp/local-ntp.html. You can press F12 to check it. It's a local resource located in
C:\Program Files (x86)\Google\Chrome\Application\{Version}\resources.pak
or
C:\Users\%username%\AppData\Local\Google\Chrome\Application\{Version}\resources.pak
Open it with a HEX editor, search text
cur.style.opacity = 1.0
, and replace it with
cur.style.opacity = 0.0
Tested on Chrome 77.0.3865.90 .

Google Chrome extension - to open new tab directed to url when a certain url is searched in current tab?

I am very new (started today) to writing chrome extensions but need to write a 'fairly simple' one for tomorrow...
I am really struggling to get my head round it though!
I need to write an extension that opens a new tab or window (whichever is easier!) directed at a predefined url is opened when a certain URL is searched in the current.
An example of this would be if the user typed in www.facebook.com I am trying to get the extension to then open a new tab/window with www.google.com in.
Any help would be much appreciated!
Thanks
Will
In your html of the extension you can specify an anchor tag for the action button which opens a new tab like this
content of the anchor
or if you want to do it programmatically you can
window.open('http://google.com','_newtab');
You cant get at the contents of the omnibox unless you use the omnibox api, which means they have to specify your keyword first before your extension can get at the contents. You could make it open another page once they have gone to a url. You could use a content script that has a matches field that matches the page your interested in and then open a page accordingly.
Content Scripts
http://code.google.com/chrome/extensions/content_scripts.html
Tabs
You can use the tab api to get the current tabs details if your not in a content script. If you are in a content script you can use window.location as stated by Encore PTL. You can also use the tab api to open a tab.
http://code.google.com/chrome/extensions/tabs.html

Creating a Badge-less Google Chrome Extension

According to the docs I have made an Google Chrome Extension that I would describe as a "browser action" because it is present on all pages. However, my extension doesn't require any interaction so having a badge next to the omnibox is pretty wasteful. I have installed extensions that do not appear anywhere (except maybe in the context menu). How is that done and is that best practice?
Having page action or browser action icons is totally optional if you don't have any popup attached to them, so just remove the whole browser_action section from your manifest file.