Disable chrome extension according to url? - google-chrome-extension

Is there a way to disable the context menu (or the whole extension) unless its on twitter?
Ive tried content script setting but it doesnt work.
{
"name": "TwitterHelper",
"description": "Helps to make entering contests easier!",
"version": "0.5",
"permissions": [
"contextMenus","tabs","activeTab"],
"icons": {
"16": "icon.png"
},
"background": {
"persistent": false,
"scripts": ["myscript.js"]
},
"browser_action": {
"default_icon": "icon.png"
},
"manifest_version": 2
}
maybe query the tabs in the js but that would only not run the click event...
THanks!

Related

Get rid of "Can read and change all your data on all y.com websites" in Chrome App Extension

I'm trying to get rid of this permission requested by my app since my app technically doesn't do that. What the app does: grab event id from active tab as a variable i.e., y.com/$eventID, and button (in popup.html) that the user presses and takes them to x.com/$eventID URL.
Here is my manifest.json file:
"name": "Exit Ticket",
"version":"0.0.4",
"description": "Access your session exit tickets, right from your AV session tab.",
"permissions": [
"activeTab"
],
"icons": {
"128":"assets/synth.png",
"48":"assets/synth.png",
"16":"assets/synth.png"
},
"background":{
"service_worker": "background.js"
},
"content_scripts":[
{"matches": ["https://*y.com/*"],
"js": ["contentScript.js"]
}
],
"action": {
"default_icon": {
"16": "assets/synth.png"
},
"default_title": "Exit Ticket",
"default_popup": "popup.html"
},
"manifest_version": 3
}
My hypothesis is that the culprit is the {"matches": ["https://*y.com/*"], bit on contentscript variable. This warning appears to be making hesitant when onboarding.

Chrome extension is loading the wrong icon on Chrome startup

The following manifest is supposed to load the off.png browser action icon, but when I shut Chrome down while the on.png icon is active, it loads the same on icon automatically for some reason when I start up Chrome.
Is this some sort of a bug?
Manifest:
{
"background": {
"scripts": ["js/bg/bg.js" ],
"persistent": false
},
"browser_action": {
"default_icon": "style/off.png",
"default_title": "__MSG_mainTitle__"
},
"default_locale": "en",
"description": "__MSG_description__",
"icons": {
"128": "style/on.png"
},
"manifest_version": 2,
"name": "__MSG_name__",
"offline_enabled": true,
"version": "2.5.5"
}
bg.js:
chrome.browserAction.onClicked.addListener(function(){
chrome.browserAction.setIcon({path: "/style/" + 'on' + ".png"})
});

Simple Chrome Extension : Open an url in a new tab

I'm looking to create a "new tab" extension like Panda or the Product Hunt Extension: the user can open a new tab with my website inside, with an hidden url.
I've generated my package with the awesome Extensionizr and here is my manifest.json :
manifest.json
{
"name": "My app",
"version": "0.0.1",
"manifest_version": 2,
"description": "My awesome app",
"homepage_url": "http://myapp.com",
"icons": {
"16": "icons/icon16.png",
"48": "icons/icon48.png",
"128": "icons/icon128.png"
},
"default_locale": "en",
"background": {
"scripts": [
"src/bg/background.js"
],
"persistent": false
},
"permissions": [
"tabs",
"http://myapp.com/*"
]
}
My background.js come from this answer, the problem seems really similar.
background.js
chrome.browserAction.onClicked.addListener(function(activeTab) {
var newURL = "http://myapp.com";
chrome.tabs.create({ url: newURL });
});
I'm still getting this error when I try to run the background page from the extension settings : Uncaught TypeError: Cannot read property 'onClicked' of undefined
And when I open a new tab, Google Chrome took the advantage and display me a google search page.
I do it wrong, and I don't know how/where/why
You're completely off-track. You don't want to open a (simple) new tab, you want to replace the "New Tab page".
Daniel's answer correctly explains why your code does not work, but it won't do what you wanted.
To replace Chrome's New Tab page, you need to use Override Pages:
"chrome_url_overrides" : {
"newtab": "myPage.html"
},
Inside that myPage.html, you can add an <iframe> for your remote content.
That's because you need to register the browser action in the manifest. Here is your manifest with the browser action added at the bottom.
{
"name": "My app",
"version": "0.0.1",
"manifest_version": 2,
"description": "My awesome app",
"homepage_url": "http://myapp.com",
"icons": {
"16": "icons/icon16.png",
"48": "icons/icon48.png",
"128": "icons/icon128.png"
},
"default_locale": "en",
"background": {
"scripts": [
"src/bg/background.js"
],
"persistent": false
},
"permissions": [
"tabs",
"http://myapp.com/*"
],
"browser_action": {}
}
Here are the browser action docs: https://developer.chrome.com/extensions/browserAction

How to display a popup window just when chrome extension is installed

I need to know how to display a pop up window when an extension is installed.What I am trying to ask is that when I install my extension,at that moment itself, a popup window should be opened asking for a username and password.How can I do that?I am not familiar with this issue.
Here is my manifest.json
{
"name": "Calpine Extension",
"version": "1.0",
"description": "Log on to calpinemate",
"manifest_version": 2,
"browser_action": {
"default_icon": "icon_128.png"
},
"background": {
"persistent": false,
"scripts": ["background.js"]
},
"browser_action": {
"default_title": "Calpine Extension",
"default_icon": "calpine_not_logged_in.png"
},
"permissions": [
"*://blog.calpinetech.com/test/index.php",
"alarms",
"notifications"
],
"web_accessible_resources": [
"/icon_128.png"]
}
Try this:
chrome.runtime.onInstalled.addListener(function (details) {
if (details.reason == "install") { //reason ( enum of "install", "update", or "chrome_update" )
//Show the PopUp
}
});
http://developer.chrome.com/extensions/runtime.html#event-onInstalled

How do I change my "legacy packaged app" into an "extension"?

I have looked at the Google documentation but I can't see how to change its type.
This is the error I get on loading.
There were warnings when trying to install this extension:
'browser_action' is only allowed for extensions, and this is a legacy packaged app.
This is my manifest.json.
{
"name": "first app",
"description": "this is my first app",
"version": "1.4",
"manifest_version": 2,
"content_security_policy": "script-src 'self' https://en.wiktionary.org/; object-src 'self'",
"background": {
"page": "background.html"
},
"app": {
"launch": {
"local_path": "index.html"
}
},
"browser_action": {
"default_icon": "icon.png"
},
"icons": {
"128": "icon.png",
"16": "icon.png"
},
"permissions": [
"http://*/*",
"https://*/*",
"https://en.wiktionary.org/",
"http://en.wiktionary.org/",
"tabs",
"contextMenus",
"storage",
"unlimitedStorage",
"notifications"]
}
All I have is a right-click event at any-time while browsing and store that text for viewing on a main page. I added in the "browser_action" as the chrome store isn't alowing me to upload my extension as a "legacy packaged app", but I don't really understand what that is even after reading the documentation.
For an app use a manifest that looks like:
{
// Required
"app": {
"background": {
// Optional
"scripts": ["background.js"]
}
},
"manifest_version": 2,
"name": "My App",
"version": "versionString",
...
For an extension use
{
// Required
"manifest_version": 2,
"name": "My Extension",
"version": "versionString",
// Recommended
"default_locale": "en",
"description": "A plain text description",
"icons": {...},
// Pick one (or none)
"browser_action": {...},
"page_action": {...},
...

Resources