I don't think this has been asked yet but a chrome extension ajax other chrome extension. I tried but failed. It's being ajaxed though jquery. My main goal is to get the current chrome theme background.
I get this error:
Denying load of chrome-extension:///manifest.json. Resources must be listed in the web_accessible_resources manifest key in order to be loaded by pages outside the extension.
Code I tried:
$.get( "chrome-extension://<ID>/manifest.json", function( data ) {
console.log(data)
});
Manifest.json:
{
"chrome_url_overrides": {
"newtab": "popup.html"
},
"description": "<description>",
"browser_action": {
"default_icon": "icon.png"
},
"manifest_version": 2,
"name": "<name>",
"permissions": [ "tabs","management","*://*/*" ,"<all_urls>"],
"web_accessible_resources": ["*"],
"version": "1.0.0"
}
You cannot read the data of another extension unless the resource is listed in the web_accessible_resources section of the other extension's manifest file.
For your specific use case, you'd better use the chrome.management API to get information about the other extension:
chrome.management.get('extension ID here', function(result) {
// See https://developer.chrome.com/extensions/management#type-ExtensionInfo
});
Related
I'm using Google API (People) list and from returned JSON, I try to use image listed on "url" field:
"photos": [
{
"url": "https://lh3.googleusercontent.com/cm/AATWAfu9TeDbEEC2VEJqYuO1eGr1F7qRpGSvgKlsjMhny8UWSAB_STRGbHQYvwIQzgrp=s100",
"default": true,
"metadata": {
"source": {
"type": "CONTACT",
"id": "4da7eb9a8d9a19e5"
},
"primary": true
}
}
]
Problem is - not all images are displayed, like you can see here:
https://i.postimg.cc/BvPJLyD5/image-2023-01-11-172253699.png.
On console, I see error 403.
When I manually copy link (from "url" link above) and open it in browser, image is normally displayed. Also, when I reload page few times manually, some images are displayed and some other not (randomly).
Is there any solution for this?
It is related to logged status.
If I'm logged into Gmail or Drive, images are randomly displayed.
If I logout from Gmail and use API again, all images are always displayed. It is same for Google Drive, as you can see here: https://issuetracker.google.com/issues/229184403?pli=1
I want to initiate FilePond with pre-populated images like this:
FilePond.create(inputElement, {
"storeAsFile": true,
"files": [
{
"source": "http://localhost/products/storage/main/dark.jpg",
"options": {"type":"local"}
}
]
});
But I got this error: Error during load. 400 (can't load URL)
I want to use FilePond in replace input file mode.
I can fix error by setting server load URL and it will load images properly but then when I want to upload new files it try to send files to server URL and don't consider "storeAsFile": true option.
Problem solved. I should use something like this:
FilePond.create(inputElement, {
"storeAsFile": true,
"server": {
"load": "http://localhost/products/storage/",
},
"files": [
{
"source": "main/dark.jpg",
"options": {"type":"local"}
}
]
});
and I shouldn't set any thing like server: {'url': 'anything', 'load': 'other url'} option.
I have been trying to read up on how to use WebExtension Page Actions by reading the following docs:
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/page_action
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/pageAction
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/user_interface/Page_actions
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/pageAction/show
I am unable to find how I configure my extension to show the page action button in the URL bar when a page from example.com has loaded. All the docs seem to assume the page action icon is already visible and shows how to handle clicks on it.
First I thought I could configure it through the manifest but it does not seem to be supported in the same way as content scripts. Then I tried to find an API to call from background.js but have not found any.
How do I show my page action icon on example.com?
Starting with Firefox 59, there will be a much simpler solution. In manifest.json, just use the show_matches property of page_action:
"page_action": {
"show_matches": ["*://*.example.com/*"],
...
}
Digging around the samples I found the following that listens for page loads across all tabs and updates the icon with popup that is configured in the manifest.
background.js
/*
Initialize the page action: set icon and title, then show.
Only operates on tabs whose URL's protocol is applicable.
*/
function initializePageAction(tab) {
if (tab.url.includes("example.com")) {
browser.pageAction.show(tab.id);
}
}
/*
When first loaded, initialize the page action for all tabs.
*/
var gettingAllTabs = browser.tabs.query({});
gettingAllTabs.then((tabs) => {
for (let tab of tabs) {
initializePageAction(tab);
}
});
/*
Each time a tab is updated, reset the page action for that tab.
*/
browser.tabs.onUpdated.addListener((id, changeInfo, tab) => {
initializePageAction(tab);
});
manifest.json
"permissions": [
"tabs",
"activeTab"
],
"content_scripts": [{
"matches": ["*://*.example.com/*"],
"js": ["content_scripts/download.js"]
}
],
"page_action": {
"browser_style": true,
"default_icon": {
"19": "icons/download-19.png",
"38": "icons/download-38.png"
},
"default_title": "Some title",
"default_popup": "popup/popup.html"
},
"background": {
"scripts": ["background.js"]
}
I made a custom connector for teams that display notifications on channels and add Tab on teams.
For the tab parts -> Everything is working well
But I have a problem for the connector parts, I get an error when I try to save my settings in the developer console:
Received error from connectors {"seq":1585127802210,"timestamp":1585127814174,"flightSettings":{"Name":"ConnectorFrontEndSettings","AriaSDKT....
-> registerOnSaveHandler is called
-> setSettings is correctly set with entityId, contentUrl (same configurationUrl as the connector configuration) and the configName.
getSettings -> is called to save to my app the webhook url -> it works
-> notifySuccess is then called and
I checked on the connector dashboard everything seems fine, on the App Studio everything is green also!
I don't know what is happening..
My manifest
{
"$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.5/MicrosoftTeams.schema.json",
"manifestVersion": "1.5",
"version": "1.0.0",
"id": "ca153ede-92f2-46e7-8695-3726b5343bf4",
"packageName": "com.kagilum.icescrum",
"developer": {
"name": "Kagilum SAS",
"websiteUrl": "https://www.icescrum.com",
"privacyUrl": "https://www.icescrum.com/privacy",
"termsOfUseUrl": "https://www.icescrum.com/termsofuser"
},
"icons": {
"color": "color.png",
"outline": "outline.png"
},
"name": {
"short": "iceScrum",
"full": "Connect with iceScrum"
},
"description": {
"short": "A true Agile project management tool",
"full": "iceScrum is a web application for using Scrum while keeping the spirit of a collaborative workspace. It also offers virtual boards with post-its for sprint backlog, product backlog and others."
},
"accentColor": "#FFFFFF",
"configurableTabs": [
{
"configurationUrl": "https://preview.icescrum.com/msTeams/setupTab/",
"canUpdateConfiguration": true,
"scopes": [
"team",
"groupchat"
],
"supportedSharePointHosts": [
"sharePointFullPage",
"sharePointWebPart"
]
}
],
"connectors": [
{
"connectorId": "f00d8890-daa8-4c87-89f5-83cbab0bccd4",
"configurationUrl": "https://preview.icescrum.com/msTeams/setup/",
"scopes": [
"team"
]
}
],
"permissions": [
"identity",
"messageTeamMembers"
],
"validDomains": [
"preview.icescrum.com"
]
}
Piece of code related to
microsoftTeams.settings.registerOnSaveHandler(function(saveEvent) {
microsoftTeams.settings.setSettings({
entityId: 'icescrum-pkey-' + $scope.settings.project.pkey,
contentUrl: isSettings.serverUrl + '/msTeams/setup/',
configName: $scope.settings.project.name
});
microsoftTeams.settings.getSettings(function(settings) {
$scope.settings.webhookUrl = settings.webhookUrl;
return FormService.httpPost('msTeams/save', $scope.settings, true).then(function() {
saveEvent.notifySuccess(); //wait that the settings are really saved on iceScrum side
});
});
});
microsoftTeams.settings.getSettings(function(settings) {
$scope.setup = !settings.configName;
var tokenData = JSON.parse(localStorage.getItem("msTeams-oauth"));
var userData = JSON.parse(localStorage.getItem("msTeams-user"));
if (tokenData) {
FormService.httpGet('ws/project/user/' + userData.id + '?light=true', {headers: {'Authorization': 'Bearer ' + tokenData['accessToken']}}, true).then(function(projects) {
$scope.projects = projects;
if (settings.entityId) {
$scope.settings.project = _.find($scope.projects, {pkey: settings.entityId.split('icescrum-pkey-')[1]});
}
$scope.ready = true;
});
}
});
Full error:
angular.min.js:113 2020-03-25T20:35:25.953Z Received error from connectors {"seq":1585168484680,"timestamp":1585168525943,"flightSettings":{"Name":"ConnectorFrontEndSettings","AriaSDKToken":"d127f72a3abd41c9b9dd94faca947689-d58285e6-3a68-4cab-a458-37b9d9761d35-7033","SPAEnabled":true,"ClassificationFilterEnabled":true,"ClientRoutingEnabled":true,"EnableYammerGroupOption":true,"EnableFadeMessage":false,"EnableDomainBasedOwaConnectorList":false,"EnableDomainBasedTeamsConnectorList":false,"DevPortalSPAEnabled":true,"ShowHomeNavigationButtonOnConfigurationPage":false,"DisableConnectToO365InlineDeleteFeedbackPage":true},"status":500,"clientType":"SkypeSpaces","connectorType":"f00d8890-daa8-4c87-89f5-83cbab0bccd4","name":"handleMessageError"}
In case this helps anyone else, I spent ages today trying to get to the bottom of this and couldn't find a solution. Until...as a last gasp show of desperation I decide to use App Studio to recreate the entire connector manifest from scratch, including creating a new connector in the portal.
For some reason, this then worked fine - even though I can see that the two manifest files are identical with the exception of the ID (and I already tried regenerating the ID for the original one).
Bit late to the story, but having followed multiple github issues like this and stack overflow posts, I'm pretty convinced that its the problem with Connectors dashboard. If you made any change to settings, they are not really propageted/saved correctly.
So for example, if you changed validDomains or configurationPage URL, they won't actually do anything. You can verify that with your devtools. For me, after changing the configurationPage the Teams is still making request to old URL as well as the new one, but the old request produces error that's listed in question.
The only workaround I was able to find is to recreate connector in dashboard. Reported problem to MS Teams dev team, waiting to hear back.
Also late here, but I ran into this problem and the below was the solution after 3 days of frustration.
Despite everything mentioned in the documentation, the following is required otherwise you'll get this error. This fixed things for me.
microsoftTeams.settings.registerOnSaveHandler(saveEvent => {
microsoftTeams.settings.setSettings({
contentUrl: "https://xxxxxx.ngrok.io/teams/connector"
});
saveEvent.notifySuccess();
});
The documentation states that registering a save handler is optional and Teams will handle notify success if it's not declared. WRONG. You must register a save handler.
The documentation does not state that setSettings is required. WRONG. You must set settings or else you will receive this error.
The documentation does not state that you must save a contentURL. WRONG. You must set content URL in the setSettings. You can apparently omit other things when setting your settings, but not content URL.
The documentation does not specifically mention it, but the contentURL must comply with your validURLs in your manifest. If it does not, you'll also see this error.
So in your case, you must ensure that isSettings.serverUrl (setSettings() contentURL) does match preview.icescrum.com (manifest validURLs). If they do not, you'll see this error.
I'm writing a Chrome extension which performs a simple ajax call (based on this example from the docs):
$.ajax({
type: "GET",
url: "http://www.flags.99k.org/getFlags.php"
}).done(function(response) {
alert("SUCCESS: " + response);
}).fail(function(response) {
alert("FAILURE: " + response);
});
The request always fails, because the alert shows: FAILURE: [object Object].
The URL is valid: When I put http://www.flags.99k.org/getFlags.php in my address bar, I get this:
[{"UID": "1", "Message": "Hello"}, {"UID": "2", "Message": "World"}, {"UID": "3", "Message": "Hello World"}]
Here is my manifest.json for the extension.
{
"name": "Hello World",
"version": "1.0",
"description": "The first extension that I made.",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"permissions": [
"http://www.flags.99k.org/"
]
}
I use Chromium 17.0.963.79 (Developer Build 125985 Linux) Ubuntu 11.10.
Currently, only the root directory is allowed to be accessed, via the permissions in the manifest. You have to add a wildcard after the URI to the permissions:
"permissions": [
"http://www.flags.99k.org/*"
]
See also: Match patterns.
EDIT: The updated code did not work, because http://www.flags.99k.org/ redirects to http://flags.99k.org/ (without www). So, also whitelist this location:
"permissions": [
"http://flags.99k.org/*",
"http://www.flags.99k.org/*"
]
Instead of doing...
alert("FAILURE: " + response);
...do...
console.debug('FAILURE');
console.debug(response);
Then if you go to the console (ctrl-shift-j on windows) you'll see an object that you can expand to see all its properties and what not, that can really help. Plus have you looked at the console when doing the request? You might get some error messages there.
This could be a cross domain issue.
When you enter the URL into your address bar it works because it's being delivered to your browser from the host.
Because you are attempting to hit a full URL outside of your hosted domain - you may need to use JSONP.