-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuBlock_Origin_GSuite_policy.gs
71 lines (57 loc) · 2.87 KB
/
uBlock_Origin_GSuite_policy.gs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Related to
// https://github.com/gorhill/uBlock/wiki/Deploying-uBlock-Origin
// https://github.com/uBlockOrigin/uBlock-issues/discussions/1834
/* 1. Save the script ( this one is self supporting at the moment, doesn't require main.gs from repository https://github.com/Landsil/apps_script--GSuite_API )
* 2. Refresh Sheet
* 3. Use new manu called "uBlock" --> Create Template
* 4. You will be asked to give access to script
* 5. In the template sheet add your websites to column "A" under "Websites" and use uBlock --> Generate JSON
*/
//************************************************************************************************************************************
// Create template sheet that will be used later on for everything.
function create_template_v2() {
var activeSpreadsheet = SpreadsheetApp.getActiveSpreadsheet();
// var yourNewSheet = activeSpreadsheet.getSheetByName("AUTO_data_v2");
var yourNewSheet = activeSpreadsheet.insertSheet();
yourNewSheet.setName("AUTO_data_v2");
var AUTO_data_v2 = activeSpreadsheet.getSheetByName("AUTO_data_v2");
// Create header
AUTO_data_v2.setFrozenRows(1)
// Bold and center header
AUTO_data_v2.getRange("1:1").activate();
AUTO_data_v2.getActiveRangeList().setHorizontalAlignment("center").setFontWeight("bold");
// Content
AUTO_data_v2.getRange("A1").activate();
AUTO_data_v2.getCurrentCell().setValue("Websites");
AUTO_data_v2.getRange("A2").activate();
AUTO_data_v2.getCurrentCell().setValue("example1");
AUTO_data_v2.getRange("A3").activate();
AUTO_data_v2.getCurrentCell().setValue("example2");
AUTO_data_v2.getRange("A4").activate();
AUTO_data_v2.getCurrentCell().setValue("example3");
AUTO_data_v2.getRange("C2").activate();
AUTO_data_v2.getCurrentCell().setValue("Your string -->");
AUTO_data_v2.getRange("C3").activate();
AUTO_data_v2.getCurrentCell().setValue("Create a txt file with this string and use in Google Workspace or just manually copy paste");
AUTO_data_v2.getRange("C4").activate();
AUTO_data_v2.getCurrentCell().setValue("https://admin.google.com/ac/chrome/apps/user?f=ID.cjpalhdlnbpafiamejdnhcphjbkeiagm");
}
//************************************************************************************************************************************
// Take list of websites and asseble them into correct format
function make_JSON_v2() {
// Read data in column
var activeSpreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var AUTO_data_v2 = activeSpreadsheet.getSheetByName("AUTO_data_v2");
// Read data from "A2:A" and flatten from 2D array to 1D array
var url_list = AUTO_data_v2.getRange("A2:A" + AUTO_data_v2.getLastRow()).getValues().flat();
var payload = {
"toAdd": {
"Value":
{
"trustedSiteDirectives": url_list,
}
}
}
AUTO_data_v2.getRange("D2").activate();
AUTO_data_v2.getCurrentCell().setValue(JSON.stringify(payload));
}