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.
Related
I am developing a chrome extension. I want to redirect to a custom html page when new tab is created.
This is process.js file.
chrome.tabs.onCreated.addListener(function() {
alert("hello");
window.open('https://ucsc.cmb.ac.lk/', '_self', false);
});
This is manifest.json file.
{
"manifest_version": 2,
"name": "xxx",
"version": "1.0",
"description": "xxx",
"icons": {
"128": "icon128.png",
"48": "icon48.png",
"16": "icon16.png"
},
"browser_action": {
"default_icon": "icon16.png",
"default_popup": "popup.html"
},
"background": {
"scripts": ["process.js"],
"presistent": true
},
"permissions": [
"storage",
"notifications",
"contextMenus",
"tabs",
"activeTab",
"http://*/",
"https://*/"
]
}
alert is working. but it is not loading the page.
You are probably looking for Override Pages.
Add this code to your manifest file:
"chrome_url_overrides" : {
"pageToOverride": "myPage.html"
},
You can try this:
window.open('https://ucsc.cmb.ac.lk/', '_blank', false);
I am using background.js script to hide my page_action icon with the following code:
chrome.pageAction.hide(sender.tab.id, function(some) {
console.log(sender.tab.id);
});
However, the icon is always 'on' and never gets hidden. I do not have any other functionality which enables the icon, and according to page_action documentation, the icon should be hidden by default.
If I remove my content script from manifest.json, indeed, the icon is disabled by default.
Here is manifest.json:
{
"manifest_version": 2,
"name": "Chrome Extension",
"description": "Chrome Extension",
"minimum_chrome_version": "10.0",
"version": "1.0",
"page_action": {
"default_icon": "logo.png",
"default_popup": "popup.html"
},
"content_scripts": [
{
"matches": [
"<all_urls>"
],
"js": [
"js/vendor.js",
"js/content_script.js"
],
"css": [
"js/content_script.css"
]
}
],
"background": {
"scripts": [
"js/vendor.js",
"js/background.js"
]
},
"permissions": [
"declarativeContent",
"tabs",
"webNavigation",
"storage",
"activeTab",
"<all_urls>"
]
}
Any thoughts?
Even after searching a lot of topics in stack overflow, nothing helped me to fix this error...
I'm trying to create an extension, and for now there are simple codes in it, but unfortunately, the console is not logging 'Hello, world!' from the content_scripts file.
manifest.json
{
"manifest_version": 2,
"name": "Example",
"shortname": "exmpl",
"description": "__MSG_appDesc__",
"version": "0.0.1",
"default_locale": "en",
"author": "Mateus Akino",
"icons": {
"16": "i16x.png",
"48": "i48x.png",
"128": "i128x.png"
},
"homepage_url": "http://example.com/",
"browser_action": {
"default_icon": "i32x.png",
"default_popup": "popup.html"
},
"update_url": "http://example.com/update.xml",
"chrome_url_overrides": {
"newtab": "newtab.html"
},
"content_scripts": [{
"matches": ["*://*.youtube.com/*"],
"js": ["execute.js"],
"run_at": "document_end"
}],
"background": {
"scripts": ["background.js"]
},
"permissions": [
"activeTab", "tabs", "i18n", "management", "webNavigation", "<all_urls>"
]
}
execute.js
console.log("Hello, world!");
background.js
chrome.webNavigation.onHistoryStateUpdated.addListener(function (details) {
chrome.tabs.executeScript(null, {
file: "execute.js"
});
});
I fixed the problem, so I'm posting it here if someone else has the same issue.
Looks like the code was fine, the problem was the way I was loading the extension...
As I'm using 'Load unpacked extension', my manifest.json wasn't updating just by disabling and enabling it (neither by using Refresh extensions now).
So I removed the extension, loaded it again and it's working normally now.
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"
]
}
How can I write a simple Chrome Extension content script that will execute JavaScript (for example alert("hello");) on every page load?
So when I navigate to a page or reload a page, the JavaScript should run.
This is my manifest.json file so far:
{
"name": "Highlight some phrases",
"description": "Hightlight some pre defined text from websql database after page loads",
"version": "0.1",
"permissions": [
"tabs","<all_urls>"
],
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"content_scripts": [
{
"matches": [
"http://*/*",
"https://*/*"
],
"js": ["content.js"]
}
],
"background": {
"page": "background.html"
},
"manifest_version": 2
}
If all you need is to alert hello on every page load or reload, below is a simple demo:
Manifest.json:
{
"name": "Highlight some phrases",
"description": "Hightlight some pre defined text after page loads",
"version": "0.1",
"permissions": [
"tabs","<all_urls>"
],
"browser_action": {
"default_icon": "icon.png"
},
"content_scripts": [
{
"matches": [
"http://*/*",
"https://*/*"
],
"js": ["content.js"],
"run_at": "document_end" // Pay attention to this line
}
],
"manifest_version": 2
}
and content.js:
// alert("hello");
document.body.style.background = 'yellow';
Yes, that's enough.
And of course, don't forget to add an icon named icon.png at the same directory with these two files, then test it in Google Chrome.