How to open a browser window from the Google Calendar Add-on - google-apps-script

I'm trying to open a browser window using a Google Calendar add-on.
I've seen apps doing this, but I can't find any documents to support this option.
The methods found in Google Docs only have options to use the SpreadsheetApp, but this is not available in the calendar.
Any idea how this is achievable?
This is the expected behavior I'm looking for.
Upon clicking "NEW", a browser window should open.

var button = CardService.newTextButton()
.setText("OPEN")
.setTextButtonStyle(CardService.TextButtonStyle.FILLED)
.setOpenLink(CardService.newOpenLink()
.setUrl("https://google.com")
.setOpenAs(CardService.OpenAs.OVERLAY)
.setOnClose(CardService.OnClose.RELOAD_ADD_ON));
This is what I was looking for.
No need to use SpreadsheetApp

Related

Script when opening in the mobile version of Google Sheets

It is necessary that, in the mobile version of the Google spreadsheet (on a mobile phone), the script scrolls / activates the bottom cell of the table.
In the desktop version of Google Spreadsheets It works!! :
var ss=SpreadsheetApp.getActiveSpreadsheet();
ss.setActiveSelection('A'+ss.getLastRow());
SpreadsheetApp.flush();
But this script does not work in a mobile phone (maybe due to the reduced capabilities of the mobile version of the table).
But still I hope - Connoisseurs will prompt me something!
Long story short, onOpen() triggers do not work on mobile (as stated by Ryan), nor is there an AppScript or Macro menu. One thing that does work, though, is onEdit() triggers.
From my experience, the only way to accomplish something like this would be to implement an onEdit() function with a checkbox. This method would not be automatic when opening the sheet, but upon opening the sheet on mobile, the user could then check off that box, and the script would run. Let me know if this is a method you would be interested in trying out, and I can edit this post to provide you with some code (I am not providing it initially since it doesn't really answer your question or truly solve your issue).
This probably isn't an issue with your code but the fact that googles mobile apps don't support Google Script or their triggers, Try using the mobile browser view of google sheets that might work.

Automatically open an gmail addon card without user clicking on the addon icon

I am looking for a way (I understand does not really seem a good idea) to force my Gmail addon to automatically open a card and display the same.
Basically, the addon should check the current email's tags and then auto trigger some 'showPanel' of the addon.
I see some answers about google sheets, but not getting how to go about this in the Gmail addon without user triggering it.
Additional Chrome Extension way ??:
If this is not something possible. I also have a chrome extension (which the users will have installed) clicking on a link created by the chrome extension can I somehow trigger the addon icons click event?
Apologies if this basic stuff, not able to find any direct useful info.
There is a Chrome extension that allows you to automaticlly open an addon from Gmail, Calendar, Drive and Docs when you open the page in the browser.
https://chrome.google.com/webstore/detail/auto-open-add-on/bcjnialkobgkdkbdclhdnbdcdgdcgdlo

How to show images on text hover in google docs addon

I am new to google docs Add-ons. I am working on an add-on in which I need to show set of image on text hover like tooltip in html
I did not find a way to implement this after hours of googling. please help.
This is not possible.
The above because the Documents Service of Google Apps Script doesn't include "on hover" event / trigger or something similar
The only way is by using a dialog or sidebar and they can only be launched by clicking on a custom menu or by using google.script.run on a previously opened dialog / sidebar.
References
https://developers.google.com/apps-script/guides/doc
https://developers.google.com/apps-script/guides/triggers
https://developers.google.com/apps-script/guides/dialogs
Related
Show Popup of YouTube video within Google Doc

google apps script & picker in iframe

The problem with displaying google picker in apps script when placing the script in a iframe of another web site. When you call the picker, a white square is displayed.
Not in the frame of another web site, the picker works fine.
HtmlService google apps script
function doGet() {
return HtmlService.createTemplateFromFile('form.html')
.evaluate()
.setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);}
https://stackoverflow.com/questions/40842627/embedding-google-apps-script-in-an-iframe#answer-40843413
The picker is based on this documentation -
https://developers.google.com/apps-script/guides/dialogs#file-open_dialogs
I decided to try a demo premium script File Upload Form.
https://ctrlq.org/code/19747-google-forms-upload-files
Will insert the script into the frame, but the result was similar - an empty white square.
https://script.google.com/macros/s/AKfycbxlX3r_dt_ZLZC9TqloaqtdextROJoIH9mUDu3MWOiXtI6ADhqb/exec
Example
http://jsfiddle.net/qqq7df51/
Whether it is possible to solve this problem.
I know that this is an old post, but it was the closest that met the search for the white-blank picker issue when the Google Picker is called from a Google Apps Script web app with the error.
Incorrect origin value. Please set it to - (window.location.protocol + '//' + window.location.host) of the top-most page
The suggestion in the error log didn't work for me, but I found a clue here.
My solution was to set the Picker site origin to the site that my iFrame was in.
For example, if I embedded my web app in 'https://www.example.com' then my picker method would be:
.setOrigin("https://www.example.com")
An example of the full constructor might look like this:
//Builds the picker
const picker = new google.picker.PickerBuilder()
.enableFeature(google.picker.Feature.SUPPORT_TEAM_DRIVES)
.setOAuthToken(config.oauthToken)
.addView(view)
.setDeveloperKey(config.developerKey)
// .setOrigin(google.script.host.origin) // Don't use this.
.setOrigin("https://www.example.com") // Add your base URL here.
.setSize(DIALOG_DIMENSIONS.width,
DIALOG_DIMENSIONS.height)
.setCallback(pickerCallback)
.build()
If you intend to use Web App project as standalone and as embedded version at the same time, the same file picker will require different origin urls. To avoid hard-coding and chaning urls, I just get the right one from ancestorOrigins. It's the last one in array.
var url = window.location.ancestorOrigins[window.location.ancestorOrigins.length-1];
new google.picker.PickerBuilder().setOrigin(url);
As mentioned in Enum XFrameOptionsMode,
Setting XFrameOptionsMode.ALLOWALL will let any site iframe the page, so the developer should implement their own protection against clickjacking.
With this, you may want to check implementation of protection against clickjacking. Try to add the X-Frame-Options HTTP Response header to any page that you want to protect from being clickjacked via framebusting.
For more information, visit Clickjacking Defense Cheat Sheet.

Cycle through tabs , Google Chrome extensions API

I'm working on a slideshow extension for Google Chrome. I've created the code that fetches the right URLs and opens them in one tab each. Now I'm looking for a function in the Chrome extension API that will allow me to switch tabs programmatically, but I can't find one? Is there one and if not, what are my options?
Are you looking for the Tabs API? The update() method allows you to select a tab like this:
chrome.tabs.update(tabId, {selected: true});
The value selected has been deprecated. Use highlighted instead:
chrome.tabs.update(tabId, {highlighted: true});