My first question so be gentle...
Using Adobe Extendscript Toolkit CS6 3.8.0.12 to make a few scripts. Trying to see contents of an array in the Data Browser, specifically a pathItem in the pathItems array.
Can't seem to find a way to examine the contents of an array.
Any help is appreciated.
You can inspect elements by adding breakpoints to you script, but it seems like you cant see the contents of pathItems in the data browser. You will have to extract them into variables. E.g. like this:
var doc = app.documents.add();
var rect = doc.pathItems.rectangle(100,-100,100,100);
var pathItems = doc.pathItems;
See this image for some more hints
Here are some options I've used.
Option 1
Use Visual Studio Code with the ExtendScript Debugger. You can create ExtendScript/JSX files to run inside any Adobe product supporting ExtendScript and then set a watcher on the variable to inspect.
//foo.jsx
var myArray = ['foo', $.fileName, {a:1, b:'two'}];
'add code break here';
//.vscode/launch.json
{
"version": "1.0.0",
"configurations": [
{
"type": "extendscript-debug",
"request": "launch",
"name": "Foo Testing",
"program": "${workspaceFolder}/foo.jsx",
// "stopOnEntry": true,
// "trace": true, //debugging output
"targetSpecifier": "indesign-14.064",
"engineName": "main"
}
]
}
Option 2
Use a Logger that will output an object for inspection to a file. jasminejsx uses this Logger to do just that.
Related
I'm trying to cancel requests from studio.code.org to www.google.com/jsapi to help page loads go faster. In my locale, google is blocked, but the browser waits for 75 seconds before giving up. I'd like to prevent the delay by blocking the request (and the page seems to work fine without jsapi).
I followed the example from https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/onBeforeRequest, installed the addon. I included a console.log statement to see that my code is called, but it only shows up after the browser waits another 75 seconds trying to load the resource that I hoped to block.
I'm open to other approaches if this isn't going to work.
manifest.json:
{
"manifest_version": 2,
"name": "cancel-google",
"version": "1.0",
"permissions": [
"webRequest",
"webRequestBlocking"
],
"content_scripts": [
{
"matches": ["https://studio.code.org/*"],
"js": ["cancel-google.js"]
}
]
}
cancel-google.js:
// match pattern for the URLs to block
var pattern = "*www.google.com/jsapi";
console.log("cancelator script loaded");
// cancel function returns an object
// which contains a property `cancel` set to `true`
function cancel(requestDetails) {
console.log("Cancelling: " + requestDetails.url);
return {cancel: true};
}
// add the listener,
// passing the filter argument and "blocking"
browser.webRequest.onBeforeRequest.addListener(
cancel,
{urls: [pattern]},
["blocking"]
);
cancel-google.js should be loaded as a background script, which is true for most of the WebExtension APIs.
{
"name": "Your Addon",
"manifest_version": 2,
"background": {
"scripts": ["cancel-google.js"]
}
}
Then it should work.
Smile4ever's answer is correct but I found some other issues with my original code.
First - the 'timing' issue of my original content-script was a red herring. Although the original content script will write to the log of the page, it has no effect on loading resources. The same script, as a background script, will not write anything (that I have noticed) into the console log, but it will work.
Second - the background script needs more permissions than I had originally (more than are described in the mozilla.org link).
"permissions": [
"http://*/*",
"https://*/*",
"webRequest",
"webRequestBlocking" ]
The above permissions are adequate/excessive; you can also replace "http(s)://*/*" with the actual urls of the pages requesting the resource and the resource to be blocked.
Now that Apple's credit card offering is out, I can get 2% cash back on purchases on the web made with Apple Pay. Unfortunately, my browser of choice is Firefox, which doesn't yet support Apple Pay.
I'd like to detect attempts to check for Apple Pay support, so I can alert myself in some way and switch over Safari to complete my purchase. Per Apple's docs, this check is performed via window.ApplePaySession.
So, I've attempted the following in an extension:
manifest.json
{
"manifest_version": 2,
"name": "applepay",
"version": "1.0",
"content_scripts": [
{
"matches": [
"*://*/*"
],
"js": [
"applepay.js"
]
}
]
}
applepay.js
window.ApplePaySession = {
canMakePayments: function () {
console.log('canMakePayments');
return Promise.resolve(true);
},
canMakePaymentsWithActiveCard: function () {
console.log('canMakePaymentsWithActiveCard');
Promise.resolve(true);
},
};
I'm able to console.log(window) in applepay.js and get the whole object, but my changes to the object don't appear to take effect - it's acting like window is read-only. What am I missing?
In Firefox, content scripts (addon written in WebExtensions) don't share the same context as page scripts (website scripts).
In your content script, do something similar to this:
function notify(message) {
console.log("do something");
}
exportFunction(notify, window, {defineAs:'notify'});
After, the page script will see that window.notify exists.
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Sharing_objects_with_page_scripts
I'm working with an Azure LogicApp where the workflow have fixed values. Our DevOps tool is VSTS (Visual Studio Team Services) and because we have multiple environments to handle, I have to do some refactoring (using parametrized values) so in VSTS we'll be able to provide environment-specific values.
Thanks to 2 websites I found on Internet I managed to understand that there are 3 kind of parameters :
To understand my problem, here's my action :
I want to have my string "/work/documents" in a parameter value. So in the "Code view" I managed to use a parameter instead of a hard-coded value :
"triggers": {
"When_a_file_is_added_or_modified": {
"type": "ApiConnection",
"inputs": {
"host": {
"connection": {
"name": "#parameters('$connections')['sftp_1']['connectionId']"
}
},
"method": "get",
"path": "/datasets/default/triggers/onupdatedfile",
"queries": {
"folderId": "#{parameters('pathToRootFolder')}"
}
},
"recurrence": {
"frequency": "Hour",
"interval": 1
}
}
}
And in my parameters.json :
"sftp_1_path_root_folder": {
"value": "/work/documents"
}
Here's the final result in Visual Studio:
Am I missing something ? Why isn't the value displayed in the Designer ? Thank you for your help in advance !
When you are using Logic Apps parameters inside your Logic App definition, they are not resolved at design-time, but at run-time. Thus, you are not supposed to see them in the designer. If you run the workflow, you should be able to see the actual value at run-time.
If you want to resolve those parameters at deployment-time, then you would need to write directly from the ARM template using ARM parameters into the workflow definition. This is possible, but in some cases, it can become a bit more complex. That's why I prefer to make use of Logic Apps parameters as described here.
I'm experimenting with a Conversation where I would like to modify the output in a couple of different ways:
different output for speech or text
different output depending on the tone of the conversation
It looks like I can add extra output details which make it through to the client ok. For example, adding speech alongside text...
{
"output": {
"speech": {
"Hi. Please see my website for details."
},
"link": "http://www.example.com",
"text": {
"Hi. Please see http://www.example.com for details."
}
}
}
For the tone, I wondered about making up a custom selection policy, unfortunately it seems to treat it the same as a random selection policy. For example...
{
"output": {
"text": {
"values": [
"Hello. Please see http://www.example.com for more details.",
"Hi. Please see http://www.example.com for details."
]
},
"append": false,
"selection_policy": "tone"
}
}
I could just add a separate tone-sensitive object to output though so that's not a big problem.
Would there be any issues adding things to output in this way?
You can definitely use the output field to specify custom variables you want your client app to see with the benefit that these variables will not persist across multiple dialog rounds (which they would if you would add them to the context field).
Now currently there is no "easy" way how to define your custom selection policy (apart from the random and sequential supported by the runtime right now) - but you could still return an array of possible answers to the client app with some attribute telling the client app which selection policy to use and you would implement this policy in the client app.
I'm creating an ARM template that deploys an Web App (an Mvc Api) and a Logic App.
I'm attempting to define an HTTP Action within the Logic App such that it dynamically concatenates the base Uri of the Api as well as a property of the current item using splitOn and #triggerBody(). The base Uri itself is concatenated from a set of parameters in the ARM template into a variable variables('hockeyAppAPISettings').Uri.
Here's the relevant snipped of the action definition:
"actionName": {
"conditions": [ ],
"inputs": {
"authentication": {
"audience": "[variables('apiSettings').Authentication.Audience]",
"clientId": "[variables('apiSettings').Authentication.ClientId]",
"secret": "[variables('apiSettings').Authentication.Secret]",
"tenant": "[variables('apiSettings').Authentication.Tenant]",
"type": "ActiveDirectoryOAuth"
},
"method": "patch",
"uri": "[concat(variables('apiSettings').Uri, '/#{triggerBody()['Id']}/ScanningInProgress')]"
//"uri": "[concat(variables('apiSettings').Uri, '//#{triggerBody()[/'Id/']}//ScanningInProgress')]"
//"uri": "[concat(variables('apiSettings').Uri, '//##{triggerBody()[/'Id/']}//ScanningInProgress')]"
},
"type": "Http"
},
The "uri" section is what i'm struggling with. I've sprinkled various escape characters (\ and #) in differing patterns through out this.
I either can't get the deployment to succeed w/deployment errors like:
Unable to parse template language expression
'concat(variables('apiSettings').Uri,
'//#{triggerBody()[/'Id/']}//ScanningInProgress')': expected token
'RightParenthesis' and actual 'Identifier'. Please see
http://aka.ms/arm-template-expressions for usage details..'.
Or if I get the deployment working and then look at the code in the portal after deployment, the string concatenation doesn't seem to work properly. The variable doesn't get converted to its value.
I have validated that if I edit the Uri directly (via the portal HTML editor) using this: "uri" : "https://edited.azurewebsites.net/api/Packages/#{triggerBody()['Id']}/ScanningInProgress" the Logic App will make a patch call for each item that comes from the HTTP trigger.
What am I doing wrong?
You need to escape the inner single quotes, i.e. try
"uri": "[concat(variables('apiSettings').Uri, '/#{triggerBody()[''Id'']}/ScanningInProgress')]"
Alternatively you can use the dot notation to reference the property, i.e.
"uri": "[concat(variables('apiSettings').Uri, '/#{triggerBody().Id}/ScanningInProgress')]"
For me changing this
"uri": "[concat(parameters('APIMUrl_param'), '/sales-management/differential-reference-codes/v1/?instance=', parameters('APIDRCInstance_param'), '&filter=differentialReferenceCode%20eq%27', variables('varDRC'), '%27')]",
to this has worked
"uri": "#concat(parameters('APIMUrl_param'), '/sales-management/differential-reference-codes/v1/?instance=', parameters('APIDRCInstance_param'), '&filter=differentialReferenceCode%20eq%27', variables('varDRC'), '%27')",