Greasy Fork

Greasy Fork is available in English.

Outlook Hotmail cleanup

Remove ads on Outlook Hotmail

当前为 2023-08-19 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name Outlook Hotmail cleanup
// @description Remove ads on Outlook Hotmail
// @version 1.4.1
// @grant none
// @license MIT
// @namespace http://greasyfork.icu/en/users/759669-sly-north
// @include https://outlook.live.com/mail/*
// ==/UserScript==

function unscale(p) {
  if (p && p.style.transform) {
    p.style.transform = 'scale(1)';
    p.style.width = "100%";
    p.style.height = "100%";
  }
}

function doAll() {
  // Small ads above list of messages
  // let e = document.getElementById('OwaContainer');
  // if (e) e.innerHTML = "";

  /*
  // Small ads above list of messages v2
  // Only after an ad showed up.
  for (let e of Array.from(document.getElementsByTagName('div')).filter(e => e.innerText==='Ad')) {
    let p = e.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement;
    p.style.background = "red";
    p.style.zIndex = -100;
    p.style.maxHeight = '0px';
  }
  /**/
  /**/
  // Even when small ad space is blank
  var smallDivs = Array.from(document.getElementsByTagName('div')).filter(e => e.clientWidth > 340 && e.clientWidth < 370 && e.clientHeight > 70 && e.clientHeight < 85);
  if (smallDivs.length > 0) {
    let e = smallDivs[0];
    if (e.innerText.search('@') < 0 && e.innerText.search(' AM') < 0 && e.innerText.search(' PM') < 0) {
      console.log('- OutlookCleanup: remove small div: ', e.innerText);
      e.style.maxHeight = '0px';
      e.style.zIndex = -100;
    }
  }
  /**/

  /*
  // Old small ads above list of messages
  // for (let ad of Array.from(document.getElementsByClassName('full')).filter(e => e.innerText.match(/Ad/))) {
  for (let e of Array.from(document.getElementsByClassName('full')).filter(e => e.getBoundingClientRect().height < 100)) {
    if (e.done) continue;
    e.done = true;
    e.style.zIndex = -100;
    e.style.position = 'fixed';
  }
  */

  // Right most vertical ads.
  let main = document.getElementById('MainModule');
  if (main) {
    while (main.childElementCount == 1) main = main.firstChild;
    if (main.childElementCount > 3) {
      let e = main.children[main.childElementCount - 1];
      if (e.getBoundingClientRect().width < 200) {
        // console.log('OutlookCleanup: remove right vertical ad space');
        e.style.zIndex = -100;
        e.style.position = 'fixed';
      }
    }
  }
  for (let e of Array.from(document.getElementsByTagName('button')).filter(e => e.innerText.search('Microsoft 365') > 0)) {
    if (e.done) continue;
    e.done = true;
    e.style.zIndex = -100;
    e.style.position = 'fixed';
  }

  // Make messages not so small
  for (let e of document.getElementsByClassName('wide-content-host')) {
    unscale(e.parentElement);
  }
  unscale(document.getElementById('docking_InitVisiblePart_0'));
  unscale(document.getElementById('docking_InitVisiblePart_1'));

  setTimeout(doAll, 1000);
}

setTimeout(doAll, 3000);