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.
Related
So I explain my issue and lets see if someone knows what I'm doing wrong.
I am creating a chrome extension that adds an option in the context menu. As part of the action I need to fetch one cookie and with the value of the cookie, open a new tab.
My problem is seems to be with the Mac version (I cannot reproduce it on Windows, but I haven't tried other linux distros) that if the user has a normal window and an incognito window opened, if he has the focus on the incognito window, and does the right-click on the normal window to trigger the contextMenu action (MacOS doesn't change the focus), chrome tries to get the cookie from the incognito window and open the new tab in the incognito window, which is the one focused, instead of the window that received the right-click.
Any Idea on how to fix it?
(In order to reproduce, you need to Allow in incognito)
script.js
function openTab(info, tab) {
console.log(tab.url); // returns the clicked url, not the incognito
chrome.cookies.getAll({}, function(cookies){
console.log(cookies); // shows only the cookies of the incognito
// this will open the tab in the incognito window
chrome.tabs.create({
url: "https://www.example.com"
});
});
}
chrome.contextMenus.create({
"title":"Open tab",
"contexts":["link"],
"onclick":openTab
});
With the following manifest
{
"name": "Getting cookies context change",
"description": "Example of what goes wrong while getting cookie",
"version": "0.1",
"permissions": [
"contextMenus",
"cookies",
"activeTab",
"<all_urls>"
],
"background": {
"scripts": ["script.js"]
},
"manifest_version": 2
}
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"]
},
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.
I'm completely new to Chrome Extensions. I want the creation of a bookmark to trigger a xmlhttprequest. Right now, I'm just trying to get a new bookmark event to do a console.log and can't see what I'm missing.
Here is my manifest.json:
{
"manifest_version": 2,
"name": "Booky Desktop Integration",
"description": "Sends New Chrome Bookmarks To Your Booky Desktop.",
"version": "1.0",
"background": {
"scripts": ["background.js"],
"persistent": false
},
"permissions": [
"bookmarks",
"http://bookydesktop.com/"
]
}
Here is my js:
chrome.bookmarks.onCreated.addListener(function(id, bookmark) {
console.log("bookmark created");
});
What am I missing?
Your code works perfectly as written. You're probably not viewing the console for your background page. You need to:
Open chrome://extensions/ (or click "Extensions" in Chrome's "Settings" menu)
Ensure "Developer mode" is ticked in the top right
Open the console by clicking "_generated_background_page.html (Inactive)" in the "Inspect views" list under your extension
Each page in Chrome has its own console instance. You were looking at the consoles of ordinary web pages, instead of looking at the console for your background page.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Where to read console messages from background.js in a Chrome extension?
I am trying to write my first Google Chrome extension. All I am trying to do is is create an extension that writes a string, via console.log(), to the console when the extension's browser action icon is clicked.
Here is my manifest.json:
{
"name": "My Extension",
"description": "My Extension",
"version": "1.0",
"permissions": ["tabs"],
"background": {
"scripts": ["test.js"]
},
"browser_action": {
"default_title": "My Extension",
"default_icon": "icon.png"
},
"manifest_version": 2
}
And here is test.js:
chrome.browserAction.onClicked.addListener(function(tab) { console.log('testing'); });
I have the console open in Chrome but when I click my extension's icon nothing is displayed in the console. I've tried reloading the extension but it hasn't helped.
I am abviously doing something wrong.
Any advice would be much appreciated.
LT
Your script runs in the background page, so the message will be displayed in the background page's console.
Open the Extensions page.
Make sure that Developer mode is checked.
Under My Extension, click _generated_background_page.html to inspect it.
Click on the Console tab.