News for hackers. Stuff that matters.
Re:Show HN: Open AI is not Open – A browser extension by Tepix on Monday March 27, 2023 @12:33PM (#35328786)
> write a userscript for Chrome that will replace every occurance of a word1 with word2

here's the script from ChatGPTs response:

    // ==UserScript==
    // @name         Replace Word1 with Word2
    // @namespace    your-namespace
    // @version      1.0
    // @description  Replaces every occurrence of word1 with word2
    // @match        *://*/*
    // @grant        none
    // ==/UserScript==
    
    (function() {
      'use strict';
      const word1 = "Open AI";
      const word2 = '"Open" AI';
      const regex = new RegExp(word1, "g");
      document.body.innerHTML = document.body.innerHTML.replace(regex, word2);
    })();

Need help installing a chrome userscript? Check the multiple answers at https://stackoverflow.com/questions/5258989/manually-adding-...

PS I don't use Chrome myself.

Re:Show HN: Open AI is not Open – A browser extension by xchkr1337 on Monday March 27, 2023 @01:07PM (#35329249)
reassigning document.body.innerHTML like that seems like a really bad idea, this should be done using MutationObserver
Re:Show HN: Open AI is not Open – A browser extension by kevincox on Monday March 27, 2023 @04:14PM (#35331794)
Yup. It will recreate all elements. At the very least it will break event listeners which will break most sites. It will probably do about 8 other things that break many sites.