Remove Top Items from Shafa.ua

Remove all divs with class "b-tile-item" containing span with the word "Top"

  1. // ==UserScript==
  2. // @name Remove Top Items from Shafa.ua
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Remove all divs with class "b-tile-item" containing span with the word "Top"
  6. // @author max5555
  7. // @match https://shafa.ua/*
  8. // @grant GM_addStyle
  9. // @license MIT
  10.  
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. // Add styles for the slider
  17. GM_addStyle(`
  18. #toggleSwitch {
  19. position: fixed;
  20. top: 10px;
  21. right: 10px;
  22. z-index: 9999;
  23. display: flex;
  24. align-items: center;
  25. }
  26.  
  27. #toggleCheckbox {
  28. margin-right: 5px;
  29. }
  30. `);
  31.  
  32. // Add the slider to the page
  33. let switchContainer = document.createElement('div');
  34. switchContainer.id = 'toggleSwitch';
  35.  
  36. let toggleCheckbox = document.createElement('input');
  37. toggleCheckbox.type = 'checkbox';
  38. toggleCheckbox.id = 'toggleCheckbox';
  39. toggleCheckbox.checked = true;
  40.  
  41. let toggleLabel = document.createElement('label');
  42. toggleLabel.htmlFor = 'toggleCheckbox';
  43. toggleLabel.textContent = 'Remove Top Items';
  44.  
  45. switchContainer.appendChild(toggleCheckbox);
  46. switchContainer.appendChild(toggleLabel);
  47.  
  48. document.body.appendChild(switchContainer);
  49.  
  50. // Function to remove the specified elements
  51. function removeTopDivs() {
  52. if (!toggleCheckbox.checked) return; // Don't execute if the feature is toggled off
  53.  
  54. let divs = document.querySelectorAll('div.b-tile-item');
  55. divs.forEach(div => {
  56. let spans = div.querySelectorAll('span');
  57. spans.forEach(span => {
  58. if (span.textContent.includes('Top')) {
  59. div.remove();
  60. }
  61. });
  62. });
  63. }
  64.  
  65. // Call the function on DOMContentLoaded
  66. document.addEventListener('DOMContentLoaded', removeTopDivs);
  67.  
  68. // Check and remove any new divs every 2 seconds
  69. setInterval(removeTopDivs, 2000);
  70. })();