Read the storage from content script - firefox-addon

For some reason the log message is never fired from this content script (test.js):
var myData = await browser.storage.local.get();
console.log("ok");
It seems that it stuck for some reason with await and never continue the executing again. And I see no errors or so in the dev tools. The same blocking read from the background script works just fine.
{
"manifest_version": 2,
"name": "test",
"version": "1.0",
"permissions": [
"storage",
"<all_urls>"
],
"content_scripts": [
{
"js": ["test.js"],
"matches": ["<all_urls>"],
"all_frames": true,
"run_at": "document_start"
}
]
}

Related

Create new tab from Firefox extension doesn't works

i'm trying to create a new tab from Firefox extension, but it doesn't works.
manifest.js:
{
"manifest_version": 2,
"name": "nafy",
"version": "1.0",
"description": "NaFy",
"icons": {
"48": "icons/icon_48.png",
"96": "icons/icon_96.png"
},
"content_scripts": [
{
"matches": ["*://*.ebay.de/*"],
"js": ["background.js"]
}
],
"permissions": [
"tabs"
]
}
background.js:
createNewTab();
function onCreated(tab) {
console.log('Created new tab: ${tab.id}');
}
function onError(error) {
console.log('Error: ${error}');
}
function createNewTab()
{
let newTab = browser.tabs.create({
url:"https://www.ebay.de"
});
newTab.then(onCreated, onError);
};
What I'm doing wrong? (Everything works as expected in Chrome.)
Your background.js file is not actually a background script despite it's name, it's defined in your manifest.json as a content script.
Content scripts don't have access to the tabs API (see list of accessible APIs here).
To fix that, you need to move your background.js to be an actual background script:
{
"manifest_version": 2,
"name": "nafy",
"version": "1.0",
"description": "NaFy",
"icons": {
"48": "icons/icon_48.png",
"96": "icons/icon_96.png"
},
"background": {
"scripts": ["background.js"]
},
"permissions": [
"tabs"
]
}

Can't migrate background script to v3 in Chrome extension

I try to migrate my manifest from v2 to v3 and fail with background scripts. I get an error unexpected token. I think my syntax is correct. What I'm doing wrong? How can I migrate this setup with multiple background scripts?
manifest v2
{
"description": "Tooltip Dictionary",
"manifest_version": 2,
"name": "Tooltip Dictionary",
"permissions": [ "https://www.example.com/*", "storage" ],
"version": "1.0.0",
"icons":{
"16":"icon16.png",
"32":"icon32.png",
"48":"icon48.png",
"128":"icon128.png"
},
"browser_action":{
"default_icon": "icon32.png"
},
"content_scripts":[{
"matches":["<all_urls>"],
"js":["jquery.min.js", "tooltip.css.js", "cs.js"]
}],
"background":{
"scripts":[ "jquery.min.js","bg.js" ]
},
"commands":{
"run-script": {
"suggested_key": {
"default": "Alt+1",
"windows": "Alt+1",
"mac": "Command+E"
},
"description": "Run"
}
}
}
manifest v3
{
"description": "Tooltip Dictionary",
"manifest_version": 3,
"name": "Tooltip Dictionary",
"host_permissions": ["https://www.example.com/*"],
"permissions": ["storage"],
"version": "1.0.0",
"icons":{
"16":"icon16.png",
"32":"icon32.png",
"48":"icon48.png",
"128":"icon128.png"
},
"action":{
"default_icon": "icon32.png"
},
"content_scripts":[{
"matches":["<all_urls>"],
"js":["jquery.min.js", "tooltip.css.js", "cs.js"]
}],
"background": {
"service_worker": ["jquery.min.js", "bg.js"]
},
"commands":{
"run-script": {
"suggested_key": {
"default": "Alt+1",
"windows": "Alt+1",
"mac": "Command+E"
},
"description": "Run"
}
}
}
If I try to use a single background file, it can't be registered too, like on screenshot:

Jenkins: Get job name from an item in queue (through API)

I cannot seem to find the job name of an item in the queue through the API. Am I missing something (obvious)?
I created two dummy jobs that require a machine named "build1" that is offline.
When I access http://JENKINS_URL:8080/queue/api/json I get this:
{
"_class": "hudson.model.Queue",
"discoverableItems": [],
"items": [
{
"_class": "hudson.model.Queue$BuildableItem",
"actions": [
{}
],
"blocked": false,
"buildable": true,
"id": 262,
"inQueueSince": 1529331225093,
"params": "",
"stuck": true,
"task": {
"_class": "org.jenkinsci.plugins.workflow.support.steps.ExecutorStepExecution$PlaceholderTask"
},
"url": "queue/item/262/",
"why": "build1 is offline",
"buildableStartMilliseconds": 1529331225094,
"pending": false
},
{
"_class": "hudson.model.Queue$BuildableItem",
"actions": [
{}
],
"blocked": false,
"buildable": true,
"id": 260,
"inQueueSince": 1529331219128,
"params": "",
"stuck": true,
"task": {
"_class": "org.jenkinsci.plugins.workflow.support.steps.ExecutorStepExecution$PlaceholderTask"
},
"url": "queue/item/260/",
"why": "build1 is offline",
"buildableStartMilliseconds": 1529331219128,
"pending": false
}
]
}
And if I access http://JENKINS_URL:8080/queue/item/262/api/json I get nothing more (just the item itself).
However, if I create an item that is put on hold because crontab-created and there's the previous one still in execution, it's no longer a hudson.model.Queue$BuildableItem but a hudson.model.Queue$BlockedItem and there, the task key has a full object with more details... and the name.
Any idea as to where I can find the job name of any item in the queue (and not a specific queue, btw)?
Thanks!

Atlassian Connect Express: Credentials rejected at connect-ace.atlassian.net

I'm evaluating atlassian-connect-express and just created an app
boilerplate with "atlassian-connect new", and then deployed it via ngrok
to my Jira dev account.
That works fine, but when I try to use the file "credentials.json" with
my account data, the plug starts with the error message:
Failed to register with host https‍://michael%40...:[My
password]#connect-ace.atlassian.net (401)
Add-on not registered; no compatible hosts detected
I get a similar message when I go to the url connect-ace.atlassian.net
Here my atlassian-connect.json
{
"key": "my-add-on",
"name": "Ping Pong",
"description": "My very first add-on",
"vendor": {
"name": "Angry Nerds",
"url": "https://www.atlassian.com/angrynerds"
},
"baseUrl": "https://xxxxxxx.ngrok.io",
"links": {
"self": "https://xxxxxxxx.ngrok.io/atlassian-connect.json",
"homepage": "https://xxxxxxx.ngrok.io/atlassian-connect.json"
},
"authentication": {
"type": "jwt"
},
"lifecycle": {
"installed": "/installed"
},
"scopes": [
"READ"
],
"modules": {
"generalPages": [
{
"key": "hello-world-page-jira",
"location": "system.top.navigation.bar",
"name": {
"value": "Hello World"
},
"url": "/hello-world",
"conditions": [{
"condition": "user_is_logged_in"
}]
},
{
"key": "hello-world-page-confluence",
"location": "system.header/left",
"name": {
"value": "Hello World"
},
"url": "/hello-world",
"conditions": [{
"condition": "user_is_logged_in"
}]
}
]
}
}
and my credatials.json
{
"hosts": {
"connect-ace.atlassian.net": {
"product": "jira",
"username": "michael#---",
"password": "---password---"
}
}
}
How can I get my dev account working with connect-ace?
Two things to check:
1 - Check the if the credentials.json has correct values. host url should start with https://. Password is the api token generated from here.
{
"hosts": {
"https://<your atlassian site name>.atlassian.net": {
"product": "jira",
"username": "<jira user name>",
"password": "<Token created from https://id.atlassian.com/manage/api-tokens>"
}
}
}
2- Enable development mode at Settings -> Apps -> Manage Apps -> Settings. (This is required if the app is not published in marketplace)
This error is a default from atlas-connect
Print error image
In atlasssian-connect.json
replace this :
"lifecycle": {
"installed": "/installed"
},
for this:
"lifecycle": {
"installed": "installed"
},
Have you tried spawning your own cloud instance and testing it there? If not yet, try creating one here. Once successfully registered, in your credentials.json, change "connect-ace" with your baseUrl/sitename and with the right credentials, it should automatically install it for you.

API Call 'tabs.captureVisibleTab' is not supported in Edge

I'm using Edge on Windows 10 v1703, build 15063.296.
The documentation (https://learn.microsoft.com/en-us/microsoft-edge/extensions/api-support/supported-apis) states, that the API tabs.captureVisibleTab is available.
But when I use it in the background script, I'm getting the following error:
API Call 'tabs.captureVisibleTab' is not supported in Edge.
The code is:
browser.tabs.captureVisibleTab(currentTab.windowId, {format: "png"}, function (data) {});
Am I missing something?
UPDATE:
this is my manifest file (ported from Chrome):
{
"author": "Evgeny Suslikov",
"background": {
"page": "background.html",
"persistent": true
},
"browser_action": {
"default_icon": {
"19": "images/sss_19.png"
},
"default_title": "FireShot - Capture page",
"default_popup": "fsPopup.html"
},
"commands": {
"last-used-action": {
"suggested_key": {
"default": "Ctrl+Shift+Y",
"mac": "Command+Shift+Y"
},
"description": "__MSG_options_label_last_action_hotkey__"
}
},
"default_locale": "en",
"description": "__MSG_application_description__",
"icons": {
"16": "images/sss_16.png",
"32": "images/sss_32.png",
"48": "images/sss_48.png",
"128": "images/sss_128.png"
},
"Key": "B5SSrXXpDZAoT8SQ4vAzNeTQ1tBC2Z24nx+hHZXfykmVYfMy5aOwPkf0Hbt7SXlKbprwV0GwrYgCwIDAQAB",
"manifest_version": 2,
"name": "__MSG_application_title__",
"offline_enabled": true,
"optional_permissions": [
"tabs",
"<all_urls>",
"downloads"
],
"options_page": "fsOptions.html",
"permissions": [
"activeTab",
"tabs",
"contextMenus",
"nativeMessaging"
],
"short_name": "FireShot",
"version": "0.98.92",
"web_accessible_resources": [
"images/*.gif"
],
"-ms-preload": {
"backgroundScript": "backgroundScriptsAPIBridge.js",
"contentScript": "contentScriptsAPIBridge.js"
},
"content_scripts": [{
"matches": ["<all_urls>"],
"js": ["scripts/fsUtils.js", "scripts/fsSelection.js", "scripts/fsLinks.js", "scripts/fsContent.js"]
}]
}
In my fsBackground.js page I do the call:
browser.tabs.captureVisibleTab(windowId, {format: "png"}, function (data) {});
I get the following error: click to see screenshot...
That function is supported starting from Edge 15. On previous versions it was still unsupported, even though the documentation said differently.
Make sure to download the latest version of Microsoft Edge Extension Toolkit and to regenerate the bridge files with it.
You can look at the generated backgroundScriptsAPIBridge.js file to see what's changed.
Previous versions (unsupported):
captureVisibleTab(windowId, options, callback) {
bridgeLog.LogUnavailbleApi("tabs.captureVisibleTab");
}
New version (supported):
captureVisibleTab(windowId, options, callback) {
bridgeLog.DoActionAndLog(() => {
myBrowser.tabs.captureVisibleTab.apply(null, arguments);
}, "tabs.captureVisibleTab");
}

Resources