Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function findText(item) {
- var background = '#' + (Math.random().toString(16) + "000000").substring(2,8)
- Logger.log(item)
- var searchResult
- searchResult = DocumentApp.getActiveDocument().getBody().findText(item)
- Logger.log(searchResult)
- while (searchResult !== null) {
- searchResult.getElement().asText().setBackgroundColor(searchResult.getStartOffset(), searchResult.getEndOffsetInclusive(), background)
- searchResult = DocumentApp.getActiveDocument().getBody().findText(item,searchResult)
- }
- }
- function highlightProblem(){
- var words = ["very", "so", "totally", "really", "for", "to"]
- words.forEach(findText)
- }
- function onOpen(){
- DocumentApp.getUi().createMenu('Fix your trash').addItem('Highlight_Common_Mistake', 'highlightProblem').addToUi()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement