JSFiddle - React, Tailwind, and code Playground

by sfoster

JavaScript

function blocker_init() {
	// a function that is given data specifying what sites and paths to block.
}

function blocker_test_url() {
	// a function that is given a URL, and returns if it should be blocked or not.
}


/// Don't edit below this line
function mozilla_init() {
  var blocklist  = '{"site.com":["blinking.gif"],"test.net":["ads/","popup.js"]}';
  var urls = ["http://mozilla.org/", "http://site.com/index.html","http://site.com/blinking.gif", "https://test.net/popup.js", "http://test.net/ads/promo.html"];
  var expected = [false, false, true, true, true];

  blocker_init(blocklist);

  for (var i = 0; i < urls.length; i++) {
    var blocked = blocker_test_url(urls[i]);
    console.log((blocked == expected[i] ? " [OK] " : "[FAIL]") +
      " Checking #" + i + ": " + urls[i]);
  }
}

mozilla_init();