How do you get the url of the script your running in Google scripts? - google-apps-script

If your making a script using the Google script editor, how do you get the url of the script your running in the google script editor in google docs? (sorry for not capitalizing the word google)

If I'm understanding your question, you can choose the "Publish" -> "Deploy As a Web App..." menu item. From there, the pop-up will show "Deploy as Web App" with a text box underneath containing the URL. Grab that (or click the "latest code" link just below it). You don't have to follow-through on the re-deploy (if you do, you'll want to use the URL it presents in a pop-up after doing so)
If you haven't previously deployed it, you'll need to save a "version" and deploy it, as touched on here. Upon doing that, it will present you with the Url in a pop-up as mentioned above. If you miss it, the the first part of this answer applies.

Related

Use Google App Script to prevent user opening url link in Sheets if site is already open in another browser tab

I've got a Google Sheet that contains numerous hyperlinks.
I'd like to prevent the user from opening multiple instances of the same site.
ie. user clicks the hyperlink in one cell which opens the linked site in a new tab, then attempts to click the same hyperlink while the first new tab is still open - I'd like a dialogue box to appear saying that they cannot open this second new tab until they have closed the first one.
Is this possible via Google App Script?
Many thanks!
Unfortunately not. GAS has no access to your browser data and cannot know what tabs are open.Moreover, GAS has no way of intercepting hyperlink clicks from within a spreadsheet, it can only do that in a side bar, modal (or modeless) dialog, a custom or an add-on menu or an image with a script attached to it.

Is there a way to remove big blue bar on top of google documents after running a script using google apps script

I am creating a google apps script for a private reason but this is nothing about the code. If you are confused by the title, I will explain what I mean:
I'm pretty sure most google drive users have used add-ons before. When you launch an addon, it runs a script. Perfectly normal, but the thing is, you don't know when it is running a script because there isn't anything indicating it. What I want is to hide that big blue bar that appears when you run a script.
I tried looking at Google Apps Script's website but if you tried searching something like this on the web, your browser won't understand you which is why I decided to use stack overflow.
Here is a picture of what I want to get rid of:
as you can see here the I want to hide the "Finished Script" thing using Google Apps Script or some other way.
Based from this blog, as soon as you click the Apps Script button, you’ll see a yellow bar "Running function <function-name>". This will indicate that the script is running. When done, the bar will read “Finished Script”. This is a built-in Google Apps Script feature. I think you will not be able to remove this feature.

Custom sidebar addon for Google Docs

I am trying to write a simple add-on for Google Docs. It basically a list of items I want to have visible on the side when I am using Docs. I followed this simple tutorial.
I don't want to publish such a simple add-on unnecessarily. Is there a way that I could use it just within my Google Docs without publishing it ?
If you've just copied the sample code into your document's script, it already works there. To activate the script you have to reopen the document, then in the menus at the top click Custom Menu -> Show sidebar.
You only have to publish a script if you want to share your add-on with other users.
If you still have problems, take a look at Add-on Quickstart. It describes add-on creation process in details.

google app script documentation clear formatting api

I would like to write a google app script to automatically clear the default text formatting of my uploaded/converted google text documents. When editing a google document in google drive, this can be done manually by selecting the text and clicking the the "Format\Clear formatting" drop-down menu item.
I am wondering if there exists such google app api or apis or any other suggestions for doing this programmatically?
Google Apps Script can't run on document upload. So you can't do this without having to install script on every document. And it takes longer than just pressing Ctrl+A and clicking the clear formatting button.

How to apply a Google Apps script to a gmail message from gmail screen

If I have a Google Apps Script that does some processing to a single gmail message, how can I trigger it from the gmail web interface so it gets applied to the message I have currently open on screen?
The closest way I've found is to apply a label and have a background process monitoring labels. Is there a way to add a button or menu option to gmail instead?
Thanks
No, there isn't. At least not using any "native" Apps Script or Gmail feature. You'd have to write a browser extension to achieve this.
Another thing you could do (aside from the special label) is to gmail's URL (while viewing the message) and paste it in your Apps Script interface (previously opened in another tab). Then your script can extract the message id from the URL and work on it right away.
Also, you could do something clever like having your script receive the id (or full gmail url) from a parameter on the script's own url, e.g. https://script.google.com/macros/s/<your-script-key>/exec?gmail=<url>
Then set up your browser (I know Chrome and Firefox do this) to trigger your script and pass the parameter based on a keyword in the location bar. I use mostly just one letter (like "y script" searches the word "script" on youtube. If you use for example "a", you could hit ctrl+L (select location bar), ctrl+c (copies gmail url), ctrl+t (new tab), then type "a ", ctrl+v, enter. Not exactly clicking a button on the gmail's interface, but does the job rather easily. If you're inclined to keyboard shortcuts like I am, this is even a preferable way :)
Another options is to label your message with some label and have an app script scan for this label every X minutes and process all messages it finds.