Open window and send POST data - google-apps-script

I'm building an Add-on that needs to open a window and send some for data (via POST) to a remote server. I can do either of those items fine - UrlFetchApp() for sending the data, and an anchor tag to open a new window, but I couldn't find a way to do both of them together.
Basically I need to send the user to another website temporarily and provide that website with some data entered within the Add-on. I tried doing this with pure javascript, but the window.open() method is not available within the GAS sandbox.
Thanks!

Its not possible in apps script (and not possible in javascript either).
What you need is to open the external site with anchor & needed parameters (post data) in the url itself. Your external url in its javascript must convert the params to a Post (or handle it directly in its server's Get)
Also, if the external page is for doing some authentication with callback (like oauth flow) apps script now support such 'oauth callbacks'

Related

Can the manifest file be dynamic in Chrome Apps?

I am writing a Chrome App that communicate with a web page. For that I have added something similar in my manifest file.
"externally_connectable": {
"matches": ["*://*.example.com/*"]
}
But the "example.com" has to be dynamic as individual customers has their one web server.
Is there any possibility, user(who install the app) can change the externally_connectable site/s.
There is an alternative way a web page can communicate with extension through content script. This approach can be used if both web page and extension are done by you.
E.g.
web page <--> content script of extension <--> background script of
extension <--> native application
For web page to content script of extension communication use window.postMessage and window.addEventListener
For Google Chrome browser,
For content script of extension to background script of extension communication use chrome.runtime.sendMessage and chrome.runtime.onMessage.addListener
For background script of extension to native application communication use chrome.runtime.sendNativeMessage
Please make sure your code has necessary security in place.
As far as I know the "externally_connectable" is the only official way to send messages (With data) from a web page as mentioned here
This requires a predefined values for every single domain. But what if you want to make only one extension to accept messages from any web page?
If you just want to notify the other side about some thing, you can use the native JS Event dispatching it on the document from one side and listening to it at document also from the other side as the document is shared between the extension content script pages and the web page.
You can't use JS CustomEvent to send data as every time you send data, you receive it empty as a result of sandbox effect of any extension.
If you want to share data so the only workaround I know so far - after spending about one month developing an extension - is to have a combination between some sort of a storage and the JS native Event mechanism.
The solution in steps (suppose you need the web page to send some data to the extension):
Make an event on document from the web page.
Save the data temporarily inside any storage technology you prefer
(localStorage, the DOM itself, or what ever..)
Receive the event at the other side (extension) by listening on the
document.
Read data and remove it.
Hope this helps someone or open a door for a discussion on a better way doing this.

Chrome extension authorize in new tab

I'm trying to implement user authorization for chrome extension.
I want to open new tab, log in there and receive access token and next get back to extension tab to update options page (show user is logged).
I use chrome.identity.launchWebAuthFlow but it opens new window instead of tab as I'd like to.
I want to achieve login similar like in Pocket extension.
Do you have any suggestions?
Then you will need to forgo using the chrome.identity API. There is no such option.
Instead, you'll have to do magic with content scripts to extract the resulting token, and you might have some problems with regards to callback URL - you can no longer use the one provided by the identity API.

Does google reCAPTCHA have access to my form fields?

Google has come up with a new reCAPTCHA,that analyse the user interaction with the form to determined if it is a bot or a real human.
I tried to find information regarding the reCAPTCHA control access to the actual form fields.
I am concern that sensitive information might rich to Google from the analysis...
Any one has any insight about it?
reCAPTCHA is added to the page by a <script> element.
<script> elements load JavaScript into the page.
JavaScript in the page has access to the full DOM of the page, including the form fields and is capable of making HTTP requests to send the data to places.
By putting their script in the page, you are giving Google access to your data.
You would have to reverse engineer the script or watch the Net tab very carefully to determine if their script uses that access to send the data to their servers.
Since the script is hosted on their servers, if it doesn't send your data to Google now, it is possible for Google to change the script so it does in the future.
Whenever you use any JS hosted by a third party, you have to trust the third party.
As far as i know the recaptcha does not have any knowledge about your form fields.It is only concerened with the text you are entering in the captcha and to send a response acoordingly.
Hope this helps

Is it possible to access web viewer content in Filemaker Pro?

I am developing Filemaker application that uses web viewer.
I need to access to DOM or Window object inside web viewer control so that I can send some messages(or trigger predefined events) to web page from Filemaker.
So the goal is to make web page inside web viewer control get some data that Filemaker sends at any time. Web page is a local html file of which URL starts with file:///.
Is it possible to do this or is there another way to accomplish this task?
It's much easier to send a message from the web viewer to FileMaker using the fmp url protocol (which you can use to e.g. call a script in FileMaker from Javascript).
You can't send a message directly to the web viewer from FileMaker. Your best bet is to set a variable on a service somewhere and have the web viewer poll that service to see if the value changes.
"This task" is not well-defined, IMHO. What exactly are "messages" or "predefined events"? You certainly can use the Set Web Viewer script step to make the web viewer load another URL at any time you wish to.
Note also that you can use Data URI to load data into the web-viewer directly, without requiring an external HTML document.

Google Chrome Extension for interacting with a web application

hope somebody understand and can maybe explain me my idea.
My Goal:
I would like that the user can use my web application, but the requests for parsing urls, etc will not run on my server, but
are processed on the client side via the browser.
My theoretical example:
There is a web application the user need to login.
If the user is logged in, he can paste ten urls into a textinput box and than push a button.
Then a ajax request is made to the server and the urls are parsed and the site informations from the parsed urls comes back as json to display it in the frontend.
Ok now my real question.
Is it possible to create a Google Chrome Extension that catches the Post request from the textarea, and send the urls to the
background.js. than the background.js should request this urls via javascript xmlhttprequest to bypass the cross-orgin restriction.