0

First hides those boxes that cover the last minute of "some website's" videos

javascript:(function(){ let q, qq;
  qq=document.getElementsByClassName("ytp-ce-element");for(q of qq){q.style.display="none";}
  })()

This works when invoked as a bookmarklet.

Second one removes sidebars, and expands the meat of (some of) our prez's favorite medium

javascript:(function(){ let q, qq;
  qq=document.querySelectorAll("[role=banner]");for(q of qq){ q.style.display="none"};
  qq=document.querySelector("[data-testid='sidebarColumn']"); qq.style.display="none";
  qq=document.querySelectorAll(".r-rthrr5"); for(q of qq) {q.style.width="100%"; q.style.maxWidth="100%"};
  qq=document.querySelectorAll(".r-1ye8kvj"); for(q of qq) {q.style.width="100%"; q.style.maxWidth="100%"};
  qq=document.querySelector("[data-testid=primaryColumn]"); qq.style.width="81%"; qq.style.maxWidth="82%";
  })()

This does not work as a bookmarklet, but both work just fine when dropped into Firefox's developer tools.

Why does only the first one work as a bookmarklet and then both work in DevTools?

Tot Zam
  • 8,406
  • 10
  • 51
  • 76
user38715
  • 3
  • 5
  • Any console errors? – CertainPerformance Dec 16 '20 at 01:14
  • I see the same for your YT and TW JavaScript. Weird. I have a bookmarklet for a password-protected site that does the same -- code works fine in developer console, but cannot get it to work as bookmarklet, no matter how I tweak the formatting. – Kevin Ashworth Dec 29 '20 at 00:10
  • Not enough information. Have you got a site or HTML-code to text it? What is your console error? In any case. The main reason why the code might work in console and not work as a bookmarklet is semicolons... First of all, the last line should be `})()`. And secondly you should use semicolon `;` after a statement, but not when declaration or a code block. Look here: https://stackoverflow.com/a/2717956/5410914 – ZolVas Jun 04 '21 at 15:13
  • Hi @ZolVas! Thanks for looking, but not following you. Last line is as you say, and where are/not erroneous ';'s? There are no console errors, just silent fail. – user38715 Jun 05 '21 at 17:58

0 Answers0