A Google extension without Omnibar Icon - google-chrome-extension

This is probably a simple question, but I'm trying to create a Google extension without an icon, one that just runs in the background without a popup or anything. What would I put into the manifest to get this to happen?

Simply remove this from the manifest.json:
...
"browser_action": {
"default_icon": "icon.png"
},
...
Now the app will not appear in the top bar.

Related

Chrome background.js do not run unless manually click refresh icon in extension page every time the chrome first open

Recently I am developing an extension which listens to tab change and do some stuff according to it. Now I wrote my main logic in chrome.runtime.onInstalled.addListener in background.js. I used unpacked version for development. However, to make the extension work, I need to manually go to the extension page and click refresh icon every time when first open a chrome window, otherwise, it will not work. Is there a way to make the background.js run the code without manually click refresh button? I tried onStartup but it doesn't work out.
Although not ideal, you can make the background script run persistently if you modify your manifest.json to...
{
"name": "My extension",
...
"background": {
"scripts": ["background.js"],
"persistent": true
},
...
}
This is not recommended because background scripts can use a lot of resources so you should use something like chromes messaging API to run only on set/specific events.
If you need to look into changing your background script, look at this for more information.

Scanning Text through a chrome extension to auto launch links

I'm pretty new at chrome extensions and am trying to make a simple one that automatically launches links in my emails. I am going to modify it a bit later on, but for now, this is all I am trying to do. How do I have a chrome extension automatically read the text of the current tab that I am on, or when I open emails if I can get that specific? I have a manifest file set up and currently can make the extension button launch a link, but I'd rather have this happen automatically, as I don't want to hit a button to launch a link when I could just click the link itself.
manifest.json
{
"manifest_version": 2,
"name": "MT task launcher",
"description": "This extension launches Task Links in emails",
"version": "1.0",
"background": {
"scripts": ["task.js"]
},
"browser_action": {
"default_icon": "icon.png",
"default_title": "Email Task Launcher"
},
"permissions": [
"activeTab"
]
}
task.js
chrome.browserAction.onClicked.addListener(function(tab) {
var action_url = "http://www.reddit.com";
chrome.tabs.create({ url: action_url });
});
Take a look at Official Guide, for your purpose, I think you should use content scripts ( which are injected into current web page), then read the DOM and get all the links. To open the links, you can either call window.open() or by passing message then open them via chrome.tabs.create
There are two options to do that, it's either edit the local copy of the extension or to inject the call to the extension.
Inject code as a Content script, use the matching rules as defines in the manifest file
A background page file use the 'chrome.tabs.onUpdated' event. Also, use the 'chrome.tabs.executeScript' method to inject script.

Google Chrome Extension Alert on Click

How do i display an Alert message instead of the pop up.
My goal is to launch a script when the user clicks the extensions icon. The pop up is unnecessary, in fact i would like to avoid letting the pop up to initiate all together. I want my extension to behave like the Gmail hyper link, but instead of opening a link, I want it to execute my script.
Take a look at the api.
You will want to remove the popup in your manifest and have a onClicked handler instead. It will look like this:
chrome.browserAction.onClicked.addListener(function(){
alert("stuff");
});
The important part is that you don't define a popup in your manifest as it prevents the event from firing.
Rather than a popup, I'm assuming you want to run a background script to listen for a browserAction event.
First, make sure you remove "default_popup": "popup.html" from your manifest.json. Then include the background script in "background".
Your manifest json should be something like this:
"browser_action": {
"default_icon": "image.png",
"default_title": "My Extension"
},
"background": {
"scripts": ["background.js"]
},

Click make popup disapear

I'm currently developping a chrome extension in order to watch youtube videos in a popup window while browsing an other website.
It works just fine, the problem is that if I click on a link or switch fullscreen app (Mac) the popup disapear, how can I make the popup bubble stay "for ever" ?
The manifest :
{
"manifest_version": 2,
"name": "One-Click Youtube",
"description": "Youtube on one click",
"version": "1.0",
"permissions": ["tabs" , "contextMenus"],
"browser_action": {
"default_icon": "icon.png",
"default_popup": "ytplayer.html"
}
}
There is an always on top window api for apps. A demo is here: https://chrome.google.com/webstore/detail/floating-youtube/jjphmlaoffndcnecccgemfdaaoighkel
You cannot. The popup will always close and destroy the page when it loses focus.
This behavior is by design; you need a different UI, maybe open a window with type: "popup".
If and when window type "panel" becomes available (probably never), your question can be solved better.

Chrome extension using sidebar

I've been having a look at Chrome extensions and I'd like to create an extension that interacts with a web page using a sidebar. So, user clicks button to launch extension, and the current page splits, with the right hand portion displaying my extension. I tried below, but I see nothing (working or otherwise). I'm not overly surprised it's not working as I do not have a sidebar.html file for one thing. The reason I have that in the manifest is because I saw it in another post in this site. The suggestion there was to use the "sidebar" line in manifest.json, but "sidebar" isn't even mentioned in the documentation as being a valid part of the manifest syntax.
manifest.json:
{
"name": "Test 1",
"version": "1.0",
"description": "Test Extension 1",
"page_action": {
"default_icon": "icon.png",
"default_title": "Testing",
"default_popup": "popup.html"
},
"sidebar" : {},
"permissions": [
"experimental"
]
}
popup.html:
<script>
chrome.experimental.sidebar.show();
chrome.experimental.sidebar.expand();
chrome.experimental.sidebar.navigate({path: "sidebar.html"});
</script>
I've enabled 'experimental'.
Thanks for any help.
The problem is that you are opening, theoretically, the sidebar inside your popup, not in the current page.
You should add a content script in the page, with a function that opens the sidebar. So, in your popup you should just retrieve the current tab then call this function from it.
Also, as Boris Smus said in your question, sidebars will be discontinued in future versions. So I advice you to create your own sidebar frame via content scripts.
Update
To help you, I've made a simple extension that create a sidebar on current page.
#Curtis hosted my sample extension on Github, you can clone it here.
I was looking for a sidebar solution as well and ended up at
Implement chrome.sidebar API thread.
According to the Sidebar PRD, it is already possible to create sidebar by:
injecting a script into the page which edits the HTML of the page to display a sidebar by modifying the DOM to insert an iframe which
loads the contents of the sidebar from a remote server.
the injected script can edit the DOM directly to display a sidebar, the contents of which are passed via message.
However, there are many downsides (explained in the same document) with regard to:
Usability, Performance, Security, Privacy (Extension sniffing as well as Third party cookies) and Accessibility.
You can watch a demo of what they are preparing for future Sidebar Component.
It might help in shipping the feature quicker if you star the thread.
update
Per this comment, Chrome will not get a built-in sidebar component.

Resources