I use a script to generate about 20 files each day from a template. That template has some functions in a google script. And for all those files I run one of the functions (pZero function below) to create an onEdit trigger which will call onMyEdit() function whenever someone edits the file. I do it on Mac or Windows in the Chrome browser. The idea is to allow other editors of that file to make use of functionality of onEdit events, when they edit the spreadsheet in Google Sheets App for Android. Everything works fine, but the problem is that for every file I need to manually run that function and system asks for authoriziation of that script. This is very time consuming and annoying (I just counted that 7 mouse clicks needed to grant access). Is there any way to automate this process or to disable authorization warnings somehow or add the function to relied functions somehow. I even tried https://myaccount.google.com/lesssecureapps to turn off authorization request, but that didn't help.
Edit: This post is related, however it's problem is regularly changing code in a single file, and that solution won't help me. My code isn't changing, I just make many copies of sheets which already have the same script in them.
function onOpen(){
// Adding my function in custome menu
var menuEntries1 = [ {name: "p0 functionality", functionName: "pZero"}];
SpreadsheetApp.getActiveSpreadsheet().addMenu("Authorize",menuEntries1);
}
function pZero(){
// Adding trigger, which calls my custom onMyEdit() function on onEdit() event
if(ScriptApp.getProjectTriggers().length==0)
var trigger = ScriptApp.newTrigger("onMyEdit").forSpreadsheet(SpreadsheetApp.getActiveSpreadsheet()).onEdit().create();
}
function onMyEdit(){
// Some code to copy from the current file to another file not owned by the user of this file.
...
}