/
Outlook-AD-Remover.user.js
54 lines (47 loc) · 1.44 KB
/
Outlook-AD-Remover.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// ==UserScript==
// @name 去除Outlook右侧广告
// @namespace http://tampermonkey.net/
// @version 0.1.0
// @description 去除Outlook右侧广告
// @author larify
// @run-at document-idle
// @match https://outlook.live.com/*
// @downloadURL https://github.com/luoweihua7/TamperMonkey/raw/master/user/Outlook-AD-Remover.user.js
// @icon https://outlook.live.com/owa/favicon.ico
// @grant none
// ==/UserScript==
(() => {
let app;
let observer;
let throttle = (callback = () => {}, time = 300) => {
let timer = -1;
return (...args) => {
clearTimeout(timer);
timer = setTimeout(() => {
callback(...args);
}, time);
};
};
let debounce = (callback = () => {}, time = 300) => {
let timer = -1;
return (...args) => {
if (timer > -1) {
return;
}
timer = setTimeout(() => {
callback(...args);
clearTimeout(timer);
timer = -1;
}, time);
};
};
let removeOutlookAD = () => {
if (document.querySelector('[aria-label="设置广告首选项"]')) {
document.querySelector('[aria-label="设置广告首选项"]').parentElement.parentElement.parentElement.parentElement.remove();
observer?.disconnect?.();
}
};
app = document.querySelector('#app');
observer = new MutationObserver(debounce(removeOutlookAD, 150));
observer.observe(app, { childList: true, subtree: true });
})();