LeopardBabaScript
Aug 14th, 2025
80
0
Never
This is comment for paste Internal link script
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const addLinks = (searchPhrase, hyperlink) => {
  2.     const document = DocumentApp.getActiveDocument();
  3.     const body = document.getBody();
  4.     let search = null;
  5.     let count = 0;
  6.     while (count < 1 && (search = body.findText(searchPhrase, search))) {
  7.         const searchElement = search.getElement();
  8.         const startIndex = search.getStartOffset();
  9.         const endIndex = search.getEndOffsetInclusive();
  10.         searchElement.asText().setLinkUrl(startIndex, endIndex, hyperlink);
  11.         count++;
  12.     }
  13.     document.saveAndClose();
  14. };
  15.  
  16. addLinks("Kiton", "https://2men.it/collections/kiton/");
Add Comment
Please, Sign In to add comment