Return Scrollable

Enable scroll functionality after blocking pop-ups on certain sites.

  1. // ==UserScript==
  2. // @name Return Scrollable
  3. // @namespace https://github.com/cilxe/JavaScriptProjects
  4. // @version 0.1
  5. // @description Enable scroll functionality after blocking pop-ups on certain sites.
  6. // @author cilxe
  7. // @match *://*/*
  8. // @icon None
  9. // @grant GM_registerMenuCommand
  10. // @grant GM_setValue
  11. // @grant GM_getValue
  12. // @run-at document-body
  13. // @license MIT
  14. // ==/UserScript==
  15.  
  16. (() => {
  17. const css = document.createElement('style');
  18. css.innerText += 'body { overflow: auto !important; }';
  19.  
  20. // Function to append the CSS to the document head
  21. function appendCSS() {
  22. document.head.append(css);
  23. console.log('CSS applied: body { overflow: auto !important; }');
  24. }
  25.  
  26. // Get stored sites from GM_getValue
  27. // eslint-disable-next-line no-undef
  28. const sites = GM_getValue('scrollableSites', []);
  29. const currentSite = window.location.hostname;
  30.  
  31. // Check if the current site is in the list and apply CSS
  32. if (sites.includes(currentSite)) {
  33. appendCSS();
  34. }
  35.  
  36. // Add keyboard shortcut [Ctrl + Alt + Shift + X]
  37. window.addEventListener('keydown', (e) => {
  38. if (e.key === 'X' && e.altKey && e.shiftKey && e.ctrlKey) {
  39. appendCSS();
  40. }
  41. });
  42.  
  43. // Function to add the current site to the list
  44. function addCurrentSite() {
  45. if (!sites.includes(currentSite)) {
  46. sites.push(currentSite); // eslint-disable-next-line no-undef
  47. GM_setValue('scrollableSites', sites);
  48. alert(`${currentSite} has been added to the list, effective after refresh.`);
  49. } else {
  50. alert('This site is already in the list.');
  51. }
  52. }
  53.  
  54. // Add menu command to add the current site
  55. // eslint-disable-next-line no-undef
  56. GM_registerMenuCommand('Set current site to append CSS by default.', addCurrentSite);
  57. })();