Namokonov

Untitled

Sep 19th, 2020
114
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function dopuskator2() {
  2.  const ss = SpreadsheetApp.getActive();
  3.  const sh = ss.getSheetByName('убираем всех');
  4.  const d = sh.getDataRange().getValues();
  5.  
  6.  d.forEach((g, i) =>{
  7.    const [url, check, delAll, newOrder] = [g[0], g[1], g[2], g[3]];
  8.    if(url && !check && (delAll || newOrder) && i > 0){
  9.       const f = DriveApp.getFileById(getIdFromUrl(url));
  10.      
  11.       if(delAll){
  12.         f.getEditors().map(g => f.removeEditor(g));
  13.         f.getViewers().map(g => f.removeViewer(g));}  
  14.      
  15.       if(newOrder){
  16.         f.setSharing(DriveApp.Access.PRIVATE, DriveApp.Permission.NONE)}
  17.      
  18.       sh.getRange(i+1, 2).setValue(true);
  19.       SpreadsheetApp.flush();
  20.  }
  21.  })
  22. }
  23.  
  24. function getIdFromUrl(url) { return url.match(/[-\w]{25,}/); }
RAW Paste Data