-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclean-FB-space.user.js
46 lines (39 loc) · 1.17 KB
/
clean-FB-space.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
// ==UserScript==
// @name Clean FB Space
// @namespace https://github.com/chgc/CleanFBSapce
// @version 0.6
// @description 移除 FB 贊助廣告
// @author Kevin Yang
// @include /https:\/\/www.facebook.com
// @grant none
// @downloadURL https://github.com/chgc/CleanFBSapce/raw/master/clean-FB-space.user.js
// ==/UserScript==
function removerightRailAd() {
var rr = document.querySelector("[data-pagelet='RightRail']");
if (rr != null && rr.children.length > 0) {
if (rr.children[0].children.length > 0) {
rr.children[0].children[0].style = 'display:none';
}
}
}
const NeedToRemoveKeywords = ['贊助', 'Sponsored'];
function checkKeywordsExist(node) {
return NeedToRemoveKeywords.some((lang) => node.querySelector('[aria-label=' + lang + ']') != null);
}
function removeSponsorPost() {
document.querySelectorAll("div[data-pagelet*='FeedUnit_']").forEach((node) => {
if (checkKeywordsExist(node)) {
node.remove();
}
});
}
function executeActions() {
removerightRailAd();
removeSponsorPost();
setTimeout(executeActions, 200);
}
(function () {
'use strict';
// Your code here...
executeActions();
})();