Advertisement
simeonshopov

Locked profiles

May 28th, 2021
1,111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function lockedProfile() {
  2.     for (const button of document.getElementsByTagName('button')) {
  3.         button.addEventListener('click', onClick);
  4.     }
  5.  
  6.  
  7.     function onClick(e) {
  8.         const elements = Array.from(e.target.parentNode.children);
  9.         const hiddenText = elements.filter(x => x.id.includes('HiddenFields'))[0];
  10.         const unlocked = elements.filter( function (x) {if (x.tagName === 'INPUT' && x.defaultValue == 'unlock') {return x;}})[0].checked;
  11.         const canHideText = e.target.textContent === 'Hide it' && unlocked && hiddenText.style.display !== 'none';
  12.  
  13.         if (unlocked) {hiddenText.style.display = 'block'; e.target.textContent = 'Hide it';}
  14.         if (canHideText) {hiddenText.style.display = 'none'; e.target.textContent = 'Show more';}
  15.  
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement