JSFiddle - React, Tailwind, and code Playground

by Miro Hristov

HTML

<div class="container">
     <div class="checkbox">
       <p>Check the box to pause the extension</p>
       <input type="checkbox" id="switcher" name="switcher">
       <p><span id="extensionStatus"></span></p>
     </div>
     <a id="submit" href="#">Save</a>
   </div>

JavaScript

if (localStorage.getItem('status') == 'paused') {
  switcher.checked = true;
}

var link = document.getElementById('submit');

link.addEventListener('click', function() {

  var status;
  var switcher = document.getElementById('switcher');
  var updateStatus = document.getElementById("extensionStatus");

  console.log('staus:', localStorage.getItem('status'));


  if (switcher.checked == true) {
    status = "paused";
  } else {
    status = "play";
  }

  localStorage.setItem('status', status);


});