pupeteer : is it possible to pause/resumethe script to modify the script? - puppeteer

1) I wonder if it is possible to pause the execution of the script to get access to the developer console in order to modify the script in runtime.
2) or maybe to run pupeteer on an opened chrome tab ?

Related

Decreasing run time of "OpenByUrl" command

I'm trying to build a web app that uses data from a certain google spreadsheet. The page loading takes a lot of time and I managed to find that the command that takes the most time is this one:
var data = SpreadsheetApp.openByUrl("https://docs.google.com/spreadsheets/d/path").getSheetByName("Form responses 1");
I want to decrease the run time of the command.
Is there a way to make the script run faster? or maybe to make some functions run parallelly?
Also, is there a way to prioritize this script \ sheet connection over other scripts or connections belonging to the same project?
Thank you
If you bind the webapp with this spreadsheet, you can use
SpreadsheetApp.getActive()
To bind copy your webapp code, open the spreadsheet needed, then click Extensions menu > Apps script and paste it there.

Google apps script run like a macro

I want to be able to run a google apps script as a "macro" with params.
For example, I navigate to script.google.com, that'll show me which scripts are available. I click one of them, then hit "Run" to run it. When I run it, I want to have the script prompt me for some input, and then it'll run some code to create a folder in Drive, some files, give permissions to those files, etc.
In terms of getting input from the person running the script, I don't care if they can pass it in somehow (like cmd line args) or if the code can just prompt the user for the input (console input is fine).
What's the best way to do this?
The Run command form the Google Apps Script editor can't open a user interface from stand alone scripts. You might use a Google Workspace Editor file (document, form, slide or spreadsheet) as a container of your script, then display a prompt, dialog or sidebar on the corresponding web application. For details see https://developers.google.com/apps-script/guides/dialogs
Also you might create your own web application. For details see https://developers.google.com/apps-script/guides/web
Also you might call your Apps Script function from other place by using Google Apps Script API. For an overview see https://developers.google.com/apps-script/api
Also you might use a CLI by using CLASP.
But maybe the simpler way is to create a function to set the values of the parameters and to call the parametrized function. In order to reduce the number of function on the IDE dropdown you set the parametrized functions as private functions (add a _ at the end of the function name)
Related
How can I test a trigger function in GAS?

Google spreadsheet script authorisation to BigQuery

I have a Google spreadsheet with a script that connects to BigQuery (using this tutorial - https://developers.google.com/apps-script/advanced/bigquery?hl=ar-AE).
It adds an extra menu option and users can run the script that executes a query to BigQuery.
It works fine for me and I want to share this spreadsheet with other users (who don't have access to BigQuery itself) and allow them to run my script. When I do it, first they get script authorisation dialog and are able to run the script after that. But BigQuery returns error:
Exception: Access Denied: Job XXX:job_NaMBWMRfbMHygS1n10AQXXXX: The user does not have permission to run a query in project XXXXX
I tried deploying the script as a web app and set it to execute under my account but it didn't change anything.
Is there any solution or workaround?
Unfortunately you can only allow access to scripts running as 'you' if it is running as a web app. The only way to run it as a webapp is if the doGet()/doPost() function is called by the browser. Running the doGet() as a function runs it as a normal script.
You can give access to run queries using the project access controls in developers console. Check out:
https://cloud.google.com/bigquery/access-control
The other option is to use the Oauth2 library and store your personal token in the scripts properties. You then can rewrite your script to use the BigQuery REST interface. There is a template for this at:
https://github.com/googlesamples/apps-script-templates/tree/master/sheets-import
The best way that I found is to simply change the configuration of the file appsscript.json. You can find by acessing View > Show project manifest. There you will find an option to change the option executeAs and if you change to USER_DEPLOYING the web app always will run as the person who deployed and most likely have the access to the BigQuery project. You can find the source of the documentation here: https://developers.google.com/apps-script/manifest

How do I view and halt running Google Apps Scripts?

I have a Google Apps Script that is running that I want to stop. I've tried deauthorizing it but that didn't work. Instead, it still tries to perform its actions, with each action (running every 5 minutes), failing due to lack of authorization. I want to halt the process entirely but I don't know how. Is there some way to view all running Google Apps Script processes for a given Google account?
Open any script in the script editor,go to the resource menu / triggers / all my triggers , choose the one you want to delete and delete it...

Google Apps Script - Tweet Approver

I've been following the guide found here: https://developers.google.com/apps-script/articles/twitter_tutorial
About creating a twitter app.
I've been looking at the part below:
To get started, copy this spreadsheet containing the script for this tutorial. Once you've got your own copy of the spreadsheet, open it and you will notice the spreadsheet will be empty; that is intentional, as we won't be using any of the spreadsheet's cells in this tutorial.The first thing you need to do is publish your script as a service. To do this, open the script editor by clicking Tools > Script Editor... In the new window, click Publish > Publish as Service...
This doesn't actually work at all.
If I open the spreadsheet and click Tools > Script Editor.. I'm taken to the script wizard. It then give me the option of creating a new script. The script can only be published to gallery, or as a web app. Where is the publish as service option?
Thanks
I checked on the tutorial page and it seems indeed that the template spreadsheet has not script included...
But the full code is still published at the end of the same page so you could copy/paste the full code in the script editor (choose new code from the wizard and delete everything in there ) and start from there.
About the "publish as service" this is the old name of what is now known as deploy as webapp, the procedure is slightly different and is described here, you will need to first save a version (manage version in the file menu) and you will get 2 urls, one for development and one for use, both will run from your browser starting with the doGet() function.
The remaining part of the tutorial about initialisation and authorization from the spreadsheet menu is unchanged, just follow the tutorial instructions.
Hoping it will help you,