-
Notifications
You must be signed in to change notification settings - Fork 0
/
twitter_meta_promoted.1.5.js
82 lines (77 loc) · 3.14 KB
/
twitter_meta_promoted.1.5.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// ==UserScript==
// @name Twitter Meta and Ad Buster
// @include *://*twitter.com/*
// @include *://www.twitter.com/*
// @include http*://www.twitter.com/*
// @namespace https://www.twitter.com
// @description Remove tweets talking about tweets
// @version 1.5
// @run-at document-idle
// @grant unsafeWindow
// 0.9 Nuke sumall.com spam
// 1.0 Remove elements with Class promoted-tweet
// 1.1 Add all Twitters events for timeline mods
// 1.2 Xpath for promoted
// 1.3 Trim inline boxes
// 1.4 Dey chenged der werds
// 1.5 Promoted by
// ==/UserScript==
function remove_meta_tweets() {
var anchors = document.getElementsByTagName('a');
for(var i=0; i<anchors.length; i++){
var raw_url = anchors[i].getAttribute('data-expanded-url');
if(raw_url && raw_url.match(/https:\/\/sumall.com\/(.*)/)) {
var parent_p = anchors[i].parentNode;
var tweet_text_container = parent_p.parentNode;
var stream_item_header = tweet_text_container.parentNode;
var content = stream_item_header.parentNode;
while (content.firstChild) content.removeChild(content.firstChild); // die die die die die
content.parentNode.removeChild(content);
}
}
}
function nuke_path(xpath, layers, seeking) {
try {
var target_elements = document.evaluate(xpath, document, null, XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null);
if (target_elements) {
var target_element = null;
while(target_element = target_elements.iterateNext()) {
let nuke_dis = target_element;
for (var layer = 0; layer < layers; layer++) {
while (nuke_dis.firstChild) nuke_dis.removeChild(nuke_dis.firstChild); // die die die die die
nuke_dis = nuke_dis.parentNode;
}
}
}
} catch(err) {
;
}
}
function tidy() {
remove_meta_tweets();
nuke_path("//span[text()='Follow']", 5, 'Lemmings');
nuke_path("//span[text()='Who to follow']", 6, 'Lemmings');
nuke_path("//span[text()='Topics to follow']", 4, 'Lemmings');
nuke_path("//span[text()='Promoted']", 6, 'Promoted');
nuke_path("//span[text()='Promoted Tweet']", 2, 'Promoted');
nuke_path("//span[starts-with(text(),'Promoted by')]", 6, 'Promoted');
nuke_path("//span[text()='Expand your timeline']", 2, 'Promoted');
nuke_path("//div[@aria-label='Set as not interested']", 4, 'Lemmings');
nuke_path("//div[@data-testid='UserCell']", 2, "Lemmings");
}
tidy();
setTimeout(tidy, 3000);
(function () {
let events = [
"scroll", "click", "uiHasInjectedNewTimeline", "uiHasInjectedOldTimelineItems",
"uiHasInjectedRangeTimelineItems", "uiHasInjectedNewTimelineItems", "uiOverlayPageChanged",
"uiPermalinkThreadExpanded", "uiExpandedConversationRendered", "uiTweetInserted", "uiPageChanged",
"uiShowRelatedVideoTweets", "uiLoadDynamicContent", "uiDMConversationUpdated"
];
for(var i=0; i < events.length; i++) {
window.addEventListener(events[i], () => {
tidy();
setTimeout(tidy, 3000);
});
}
})();