chrome extension popup not showing up - javascript

I was working on a chrome extension but the popup is not showing up when i click the icon.
I have seen some questions saying that the problem was with the page_action to be browser_action, but when i did that it didn't work and still not showing anything. I am on windows 10, latest chrome version.
Here is my mainfest.json file:
{
"manifest_version": 2,
"name": "Key shifter",
"version": "1.0.0",
"description": "select text then press ctrl + shift + e",
"icons": {"128":"icon128.png"},
"browser_action": {
"default_title": "I dont know what im doing",
"default_popup:": "popup.html"},
"permissions": [
"activeTabs",
"http://*/*",
"https://*/*",
]
}

you have two problems in you manifest,
There is extra comma(,) after the last permission
default_popup key is not valid, you have given "default_popup:" (extra colon) it should be "default_popup": "popup.html"
Updated manifest
{
"manifest_version": 2,
"name": "Key shifter",
"version": "1.0.0",
"description": "select text then press ctrl + shift + e",
"icons": {
"128": "icon128.png"
},
"browser_action": {
"default_title": "I dont know what im doing",
"default_popup": "popup.html"
},
"permissions": [
"activeTabs",
"http://*/*",
"https://*/*"
]}

Related

How can I get "document.cookie" of a current tab from a chrome extension?

This is what I've been trying to do in the console of the extension:
chrome.tabs.executeScript({code: "document.cookie"})
But for some reason, it always ends up returning "undefined" in the console logs. Is there a reason for this, or a way to get all the cookies on the current tab the extension is on?
This is my manifest.json:
{
"manifest_version": 2,
"name": "Extension",
"description": "Sample Description",
"version": "1.0",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"permissions": [
"activeTab",
"https://ajax.googleapis.com/",
"windows",
"cookies",
"tabs",
]
}

Chrome extension popup not showing?

Well this is not showing the popup help!!!! When I run it the extension looks a bit white, without colour and when i click it the popup doesn't show up. Honestly I haven't got a clue!
{
"name": "Youtube",
"version": "0.0.1",
"manifest_version": 2,
"description": "Youtube",
"icons": {
"16": "icons/icon16.png",
"48": "icons/icon48.png",
"128": "icons/icon128.png"
},
"default_locale": "en",
"page_action": {
"default_icon": "icons/icon19.png",
"default_title": "page action demo",
"default_popup": "files/popup.html"
},
"permissions": [
"bookmarks",
"chrome://favicon/",
"clipboardRead",
"clipboardWrite",
"contentSettings",
"contextMenus",
"cookies",
"fileBrowserHandler",
"tts",
"ttsEngine",
"history",
"idle",
"management",
"notifications",
"tabs",
"geolocation"
],
"content_scripts": [
{
"matches": [
"http://www.youtube.com*"
],
"js": [
"js/Youtube.js"
]
}
]
}
A page action needs to be "shown" for the button to do anything, i.e. you have to either call chrome.pageAction.show for a tab or use chrome.declarativeContent to show it.
Blame Google for crippling Page Actions so they are now unintuitive.
If you want an always-active button you need a Browser Action instead.

Chrome Extension not working on page loads

I want that if any of my webpage loads I want to simply display a simple alert on the page.
manifest.json
{
"manifest_version": 2,
"name": "Chrome Ext Demo",
"description": "chrome extension tuts",
"version": "1.0",
"content_scripts": [
{
"matches": ["http://*/* "],
"js": ["jquery.js","eventPage.js"]
}
],
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"permissions": [
"tabs", "http://*/"
]
}
I have jquery stored locally in my chrome extension folder.
eventPage.js
$("document").ready(function(){
alert("hiii");
console.log("hii");
});
I am new to building Chrome Extension. Any help would be appreciated.
Please remove the useless space in your "matches": ["http://*/* "]field, it doesn't match a valid url.
If possible, remove useless permissions if they are not used.
{
"manifest_version": 2,
"name": "Chrome Ext Demo",
"description": "chrome extension tuts",
"version": "1.0",
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["jquery.js","eventPage.js"]
}
],
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"permissions": [
"tabs"
]
}

Chrome Extension Browser Action not Appearing

I am trying to make an extension for Google Chrome, and in the early stages of coding it, the icon for the browser action would appear, but now that I've added an action to it, it won't show up. The manifest.json is here:
{
"manifest_version": 2,
"name": "Test",
"description": "Test extension"
"version": "0.1",
"background": {
"scripts": ["background.js"],
"browser_action": {
"default_icon": "icon.png"
}
}
}
You are missing a , after the description entity, and put a } at wrong place.
{
"manifest_version": 2,
"name": "Test",
"description": "Test extension",
"version": "0.1",
"background": {
"scripts": [
"background.js"
]
},
"browser_action": {
"default_icon": "icon.png"
}
}

Background.js not working Chrome Extension

I'm new to chrome extensions and cannot seem to figure out how the background concept works. I am building a counter extension that keeps counting even when the user closes the extension (but not the browser) and wanted to do a simple test to see if I could figure out how to use the background file. Below is my attempt to create a function that activates everytime a user clicks on a tab (outside of my extension) and when they click on 5 tabs, the alert hits. I cannot figure out why this doesn't work.
background.js:
var counter = 0;
chrome.browserAction.onClicked.addListener(function(tab){
counter++;
if (counter == 5) {
alert("Hi");
}
});
manifest.json:
{
"name": "Hello World!",
"description": "My first packaged app.",
"version": "0.1",
"permissions": ["tabs", "http://*/*"],
"manifest_version":2,
"content_scripts": [ {
"js": [ "jquery-1.9.1.js", "myscript.js" ],
"matches": [ "http://*/*", "https://*/*"]
}],
"background": {
"scripts": [
"background.js"
]
},
"browser_action": {
"default_title": "10,000 Hours",
"default_icon": "icon16.png",
"default_popup": "index.html"
},
"icons": {
"16": "icon16.png",
"48": "icon48.png",
"128": "icon128.png"
}
}
It is working for me with following code.
manifest.json
{
"name": "Popping Alert",
"description": "http://stackoverflow.com/questions/15194198/background-js-not-working-chrome-extension",
"background": {
"scripts": [
"background.js"
]
},
"version": "1",
"manifest_version": 2,
"browser_action": {
"default_title": "Click Me"
}
}
background.js
var counter = 0;
chrome.browserAction.onClicked.addListener(function (tab) {
counter++;
if (counter == 5) {
alert("Hey !!! You have clicked five times");
}
});
Can you share your related code or put your problem statement clearly if this does not work?

Categories

Resources