User:Acagastya/sanitaryCheck.js

const sheet = (function { // Create the tag  var style = document.createElement('style');  // WebKit hack  style.appendChild(document.createTextNode(''));  // Add the element to the page  document.head.appendChild(style);  return style.sheet; }); (function sanitaryCheck { if(mw.config.get('wgNamespaceNumber') != 0)  return; // only for mainspace  const div = [...document.getElementsByClassName('mw-parser-output')][0];  const input = document.createElement('input');  input.setAttribute('type', 'checkbox');  input.setAttribute('id', 'sanitary-check');  input.setAttribute('name', 'sanitary-check');  const label = document.createElement('label');  label.setAttribute('for', 'sanitary-check');  label.innerText = 'Sanitary check';  input.setAttribute( 'onchange', `this.checked ? sheet.addRule('.mw-body-content p', 'font-family: "Comic Sans MS", fancy') : sheet.removeRule` ); // div.append(input);  // div.append(label);  div.parentElement.prepend(label);  div.parentElement.prepend(input); });