I want to match:
http://images.orkut.com/
http://www.orkut.co.uk/
http://www.orkut.com.br/
http://images.orkut.jp/
The pattern I am trying to use is:
http://*.orkut.*/*
But when I try to load the extension it says:
invalid value for content_scripts[0].matches[0]
Is there a way to match these urls without specifying the full domain?
In the manifest file
"permissions": [ "tabs", "http://*.orkut.*/*", "https://*.orkut.*/*" ],
"content_scripts":
[
{
"matches": [ "http://*.orkut.*/" ], // error
"js": ["content/loader.js"]
}
]
A more generic doesn't work, while this one works:
"matches": [ "http://*.orkut.co.uk/" ],
You cannot do that do to security reasons, please refer to http://code.google.com/chrome/extensions/match_patterns.html for more information.
As well, team lead of Chrome Extension did a nice explanation why:
http://groups.google.com/a/chromium.org/group/chromium-extensions/msg/3d305eb340f01763
As Mohamed Mansour's answer mentioned, this is not supported by google in the manifest.json
However, you can still add a simple javascript check in your content script!
For example, this is how I workaround a similar case where I wanted the content script to be executed only on 192.168.*.* hosts (it's an in-house chrome extension)
in your manifest.json use <all_urls>
...
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["content-script.js"]
}
],
...
in your content-script.js use a simple condition to verify if the hostname matches a regex pattern
let isValidHostname = /^192.168.\d+.\d+$/.test(window.location.hostname);
if (isValidHostname){
// Do your stuff here
}
Related
Cspell (Code Spell Checker) extension for Visual studio code is not working in html.
VS Marketplace Link: link
Probably something is not correct in my config:
"cSpell.languageSettings": [ { "languageId": "*", "includeRegExpList": [ "CStyleComment" ] }, ]
I wrote "*" in my config to make it work with every language but it dint work.
I'm reading the article Debugging ES6 in Visual Studio Code and find a syntax in launch.json file that I don't quite understand.
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch App.js",
"program": "${workspaceRoot}/src/app.js",
"outFiles": [ "${workspaceRoot}/.compiled/**/*.js" ]
}
}
"outFiles": [ "${workspaceRoot}/.compiled/**/*.js" ]
What does the ** (two stars) represent? Also, does *.js match filname.js.map beside matching filename.js? I am not sure if this kind of pattern relates to regexr.
This is not a regex (because dot in ".js" does not look like it matches any character).
This is kind of fancy wildcard for a filename:
${workspaceRoot} - some environmental variable
/.compiled - exact name of folder (e.g. for generated code)
/** - any set of nested folders
/*.js - any file with js extension at path specified before
Also, does *.js match filname.js.map beside matching filename.js?
I assume that it does not, only filename.js.
the ** (double-glob) means that it will search in any number of subdirectories. For example,
a/**/b
will match
a/a/b
a/c/b
a/c/a/b
and so on.
I am developing a Gmail App Scripts Ad-On. I am able to create cards, and child cards, and add controls to the cards, and it works well. However, I need to add functionality to make an oData call to a web service in another application. As soon as I add the following line in my code.gs file I get the error shown below when I run my add-on in Gmail.
var req = new XMLHttpRequest();
ReferenceError: "XMLHttpRequest" is not defined. [line: 187, function: gotoChildCard, file: Code]
It never even gets beyond that line, so it is not any problem with oData structure or anything, it does not like that line. I have tried to find some posts, but I cannot find anything (I did find some people getting this error when they develop a Chrome Extension, but that is different - I am creating a Gmail App Scripts Add-On). I was thinking that maybe I need to add something to my manifest file, but if so, I do not know what it is.
below is my appscript.json file:
`{
"oauthScopes": [
"https://www.googleapis.com/auth/gmail.addons.execute",
"https://www.googleapis.com/auth/gmail.readonly"
],
"gmail": {
"name": "Dean's Gmail Add-On: Multiple Cards for Set ",
"logoUrl": "https://www.gstatic.com/images/icons/material/system/2x/bookmark_black_24dp.png",
"contextualTriggers": [{
"unconditional": {
},
"onTriggerFunction": "createNavigationCard"
}],
"openLinkUrlPrefixes": [
"https://mail.google.com/"
],
"primaryColor": "#4285F4",
"secondaryColor": "#4285F4",
"version": "TRUSTED_TESTER_V2"
}
}
You can only make HTTP requests using the UrlFetchApp in Apps Scripts
I'm having a hard time finding for the API in getting the contacts of the people who open the newsletter after sending it to a list of email. In the official API documentation of GetResponse, I didn't find a solution. Any idea or suggestion can help. thanks.
Though it's rather old now, I'll try to answer, maybe it helps someone.
Just as inside GetResponse web interface, you'll need to search contacts according to some criteria. These pages of the API docs describe how this is done:
http://apidocs.getresponse.com/v3/resources/search-contacts
Search contacts is the most complex part of the API. To save a search of contacts who opened a particular message you'll need to POST something like below to https://api.getresponse.com/v3/search-contacts/:
{
"name": "test_conditions", //can be any you like
"subscribersType": [
"subscribed" //can also be "undelivered", "removed" and "unconfirmed"
],
"sectionLogicOperator": "or", //or "and"
"section": [ //section can have up to 8 conditions; one saved search can have up to 4 sections
{
"campaignIdsList": [
"V" //you'll need to get campaigns' IDs with http://apidocs.getresponse.com/v3/resources/campaigns#campaigns.get.all
],
"logicOperator": "or",
"subscriberCycle": [
"receiving_autoresponder",
"not_receiving_autoresponder"
],
"subscriptionDate": "all_time", //"today", "yesterday", "this_month", "last_month", "this_week", "last_week" are also possible
"conditions": [
{
"conditionType": "opened",
"operatorType": "message_operator",
"operator": "autoresponder", //or "newsletter", or "split"
"value": "WTjXF" //message id, should be firstly got with a separate API call
}
]
}
]
}
More info on how the payload for such requests should be formed is here: http://apidocs.getresponse.com/v3/resources/search-contacts-reference
And the last point: if you don't need to save a search but only get the emails who've opened a message, in the object above you should remove the "name" property and post this to http://apidocs.getresponse.com/v3/search-contacts/contacts
More: http://apidocs.getresponse.com/v3/resources/search-contacts#search-contacts.contacts.form
I'm trying my hands at a simple Chrome Extension, but am running into a problem with providing a value for the matches array in my content_scripts.
{
"name": "My Extension",
"version": "1.0",
"description": "My Extension Experiment",
"browser_action": {
"default_icon": "icon.png",
"default_title": "Ext",
"default_popup": "popup.html"
},
"content_scripts": {
"matches": ["http://*"],
"js": ["scripts.js"]
}
}
When I try to load this extension into Chrome, I get the following message:
Could not load extension from 'C:\Users\foo\Desktop\Extensions\bar'.Invalid value for 'content_scripts'.
I cannot see what is "invalid" about my value though. What I'm trying to do is match every URL, so my extension can manipulate the DOM (via javascript within scripts.js) of any page it is ran on. Am I missing something, going about this all wrong, or what?
update
After posting this question, I did notice that the Google example was slightly different than mine, so I modified my code a bit to reflect their syntax:
"content_scripts": [{
"matches": ["http://*"],
"js": ["scripts.js"]
}]
That being said, I still get the following error when trying to load my extension:
Could not load extension from 'C:\Users\foo\Desktop\Extensions\bar'.
Invalid value for 'content_scripts[0].matches[0]'.
You need to surround the value of the content_scripts field in square brackets:
"content_scripts": [ {
"matches": ["http://*"],
"js": ["scripts.js"]
} ]
(see the Chrome Docs for more info)
Incidentally, using http://*/* would be a better match for all urls (see the docs), adding https://*/* if you also need to match those as well.
Edit:
Following your edit, the error you are getting is because of the match pattern being incorrect.
If you want to match every URL, then Google has a special pattern just for this purpose: <all_urls>
Sample usage:
"matches": ["<all_urls>"],
See this page for more info:
https://developer.chrome.com/extensions/match_patterns
Any match pattern should be of the following structure [scheme]://[host][path]
scheme is '*' | 'http' | 'https' | 'file' | 'ftp'
host is '' | '.' (any char except '/' and '*')+
path is '/' (any chars)
For matching any HTTP/S and FILE URL use:
"matches": [
"*://*/*",
"file://*/*"
],
Ref: https://developer.chrome.com/apps/match_patterns
By the way, in order to allow access to local files - add the permission:
"permissions": [
"file://*/*"
]
Or approve file access on the extension settings page.
For many that are getting errors involving:
'content_scripts[0].matches' is missing or invalid.
or
'content_scripts[0].matches[0]': Empty path.
Trying filling in, or creating, the matches field with your specific URL needed.
If you want to use all URLs, then use the <all_urls> tag like below.
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": [ "jquery.js" ]
}
]
Files listed in the "js" array have their path relative to you app.
In other words, the location of "manifest.json" is your root directory.
Note: jquery.js is a file in my project's directory and you should replace it with whatever script file you want.
After many tries following working , it matches all URL's and also supports http & https.enter code here
"manifest_version": 2,
"content_scripts": [
{
"matches": [
"*://*/*",
]
}
If you are using Jquery on a CDN, Just download it and include it to your working folder, And then try to import it
Bro you forgot to add
"manifest_version":2
Which is mandatory one.