DizaBlah

Chat GPT - SEO / Google Docs Algos

Mar 9th, 2023
17
0
Never
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