WP Poczta - Adblock

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name            WP Poczta - Adblock
// @description:pl  Adblocker for https://poczta.wp.pl
// @description:en  Adblocker for https://poczta.wp.pl
// @version         10
// @include         https://poczta.wp.pl/*
// @grant           none
// @run-at          document-start
// @namespace https://greasyfork.org/users/1628334
// ==/UserScript==

(function() {
  'use strict';

  const injectCSS = () => {
    const style = document.createElement('style');
    style.innerHTML = `
      div.pt_2.pb_2.pl_4.pr_2.bg-c_white.min-h_unset,
      div[class*="print-hide-tactic_removed"],
      div[class*="h_168px"] {
        display: none !important;
      }
    `;
    if (document.head) document.head.appendChild(style);
    else document.addEventListener('DOMContentLoaded', () => document.head.appendChild(style));
  };
  injectCSS();

  let btnClicked = false;
  let updateScheduled = false;

  const runTextChecks = () => {
    updateScheduled = false;

    if (!btnClicked) {
      const buttons = document.querySelectorAll('button');
      for (const btn of buttons) {
        if (btn.textContent.includes('Rozumiem ryzyko, przechodzę do poczty')) {
          btn.click();
          btnClicked = true;
          break; 
        }
      }
    }

    const wpDivs = document.querySelectorAll('div.flex-sh_1.trunc_true');
    for (const div of wpDivs) {
      if (div.textContent.includes('/WP')) {
        const parent = div.closest('div.group.d_flex.flex-d_column') || div.closest('div.cursor_pointer');
        if (parent && parent.style.display !== 'none') {
          parent.style.setProperty('display', 'none', 'important');
        }
      }
    }

    const pocztaDivs = document.querySelectorAll('div.textStyle_bodyBoldMd');
    for (const div of pocztaDivs) {
      if (div.textContent.includes('Poczta')) {
        const parent = div.closest('div.group.d_flex.flex-d_column') || div.closest('div.cursor_pointer');
        if (parent && parent.style.display !== 'none') {
          parent.style.setProperty('display', 'none', 'important');
        }
      }
    }
  };

  const observer = new MutationObserver((mutations) => {
    const hasNewNodes = mutations.some(m => m.addedNodes.length > 0);
    if (!hasNewNodes) return;

    if (!updateScheduled) {
      updateScheduled = true;
      requestAnimationFrame(runTextChecks);
    }
  });

  const initObserver = () => {
    observer.observe(document.body, { childList: true, subtree: true });
    runTextChecks();
  };

  if (document.body) {
    initObserver();
  } else {
    document.addEventListener('DOMContentLoaded', initObserver);
  }

})();