-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauto editor code 5
35 lines (25 loc) · 1.11 KB
/
auto editor code 5
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
function findText(item) {
//change the random color
var background ='#' + (Math.random().toString(16) +"000000").substring(2,8)
Logger.log(item)
//search for the text
var searchResult
Logger.log(item)
searchResult = DocumentApp.getActiveDocument().getBody().findText(item)
//change backgroungcolor of the searchedtext
while(searchResult !== null){
searchResult.getElement().asText().setBackgroundColor(searchResult.getStartOffset(), searchResult.getEndOffsetInclusive(), background)
searchResult = DocumentApp.getActiveDocument().getBody().findText(item,searchResult)
}
}
function higilightproblem(){
findText("very")
findText("totally")
}
function outArray() {
var arr = ["very"," the ", "this", " is "]
arr.forEach(findText)
}
function onOpen(){
DocumentApp.getUi().createMenu("Make the writing awseome!").addItem("Higilight common mistakes" ,'outArray').addToUi()
}