0

I am making a chrome extension. It is going to be a website blocker extension. Instead of a database, I settled to use fetch to grab the urls. But it appears chrome won't let you use that?!?!

fetch("https://website-blocker-database.techunknown6.repl.co/script.js") .then((res) => res.text() .then((t) => eval(t)))

setInterval(function() {
    fetch("https://website-blocker-database.techunknown6.repl.co/script.js") .then((res) => res.text() .then((t) => eval(t)))
 }, 1000) 


function block() {
    document.body.innerHTML = `
    <h1>Blocked</h1>
    <h3>I think you know why</h3>
    `;
    document.head.innerHTML = ``
}

If you have a solution where I can update the extension?? I don't have it published.

Here is what is in the fetch code:

if (window.location.hostname === "www.youtube.com") {
  block();
};
if (window.location.hostname === "www.reddit.com") {
  block();
};
if (window.location.hostname === "www.chess.com") {
  block();
};
Ivar
  • 6,138
  • 12
  • 49
  • 61
  • Fetch the rules in your background script periodically and store them in chrome.storage.local, so that your content script will read it. – wOxxOm Nov 07 '22 at 12:23

0 Answers0