Greasy Fork is available in English.
Remove user and topics to follow suggestions from Twitter
当前为
// ==UserScript==
// @name Twitter cleanup
// @version 1.3.1
// @grant Sly_North
// @description Remove user and topics to follow suggestions from Twitter
// @author Sly_North
// @match https://twitter.com/*
// @namespace http://greasyfork.icu/en/users/759669-sly-north
// @icon https://abs.twimg.com/responsive-web/client-web/icon-svg.168b89d8.svg
// @license MIT
// @grant none
// ==/UserScript==
function RemoveFollowingThinElements(e, removeWithoutFollowButton) {
// console.log('*** Removing H=', e.getBoundingClientRect().height, ' ', e.innerText);
let next = e.nextSibling;
let nextH = next.getBoundingClientRect().height;
if (next && nextH < 200) {
if (removeWithoutFollowButton || next.innerText.match(/Follow/))
RemoveFollowingThinElements(next, removeWithoutFollowButton);
else {
// console.log('Stop at H=', nextH, ' ', next.innerText);
if (next.innerText === 'Show more') {
next.innerHTML = "";
}
}
}
e.innerHTML = "";
}
function RemoveSuggestions() {
// Needs to be in screen for nextSibling to be defined.
let elts = Array.from(document.getElementsByTagName('H2')).filter(
e => e.getBoundingClientRect().top < window.innerHeight &&
e.innerText === 'Who to follow');
if (elts.length > 0) {
console.log('Found "Who to follow"');
for (let e of elts) {
e = e.parentElement.parentElement.parentElement.parentElement;
RemoveFollowingThinElements(e, false);
}
console.log('Removed "Who to follow"');
}
elts = Array.from(document.getElementsByTagName('SPAN')).filter(
e => // e.getBoundingClientRect().top < window.innerHeight &&
(e.innerText === 'Topics to follow' || e.innerText === 'Expand your timeline with Topics'));
if (elts.length > 0) {
let title = e.innerText;
console.log('Found "', title, '"');
for (let e of elts) {
e = e.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement;
// Remove topics and offset bar
RemoveFollowingThinElements(e.nextSibling, true);
// Remove title
e.innerHTML = "";
}
console.log('Removed "', title, '"');
}
setTimeout(RemoveSuggestions, 1000);
}
setTimeout(RemoveSuggestions, 1000);
// If the window is very small (like when watching a video in a small secondary window),
// remove the Twitter left column and top banner.
if (window.innerWidth < 700 && window.innerHeight < 700) setTimeout(function() {
console.log('ici');
let elts = document.getElementsByTagName('header');
console.log('side header count=', elts.length);
if (elts.length > 0) {
elts[0].style.display = "none";
}
var elt = document.querySelector('[aria-label="Home timeline"]');
if (elt) elt.firstChild.style.display = "none";
}, 500);