Skip to content

Instantly share code, notes, and snippets.

@dawnerd
Created April 15, 2019 06:38
Show Gist options
  • Save dawnerd/a0311ade9d123a65f54a05ad7960adef to your computer and use it in GitHub Desktop.
Save dawnerd/a0311ade9d123a65f54a05ad7960adef to your computer and use it in GitHub Desktop.
Update to Twitter STFO to work with new chrome
// ==UserScript==
// @name Twitter STFO
// @namespace http://twitter.com/ivanca
// @version 1.0
// @description Delete button for individual annoying tweets you hate to read again!
// @match https://twitter.com/*
// @copyright 2012+, You
// ==/UserScript==
(function () {
var w = window.unsafeWindow ? unsafeWindow : window.top;
var $ = w.$;
if(w.$){
$(ini);
} else {
Object.defineProperty(w, "jQuery", {
_this: null,
get: function() {
return this._this;
},
set: function(val) {
this._this = val;
$ = val;
ini();
}
});
}
function ini(){
var ns = "deletedBy" + ($(".account-summary").find("[data-user-id]").attr("data-user-id") || -1);
localStorage[ns] = localStorage[ns] || "";
var deleted = localStorage[ns].split(",");
if (deleted.length > 200) {
localStorage[ns] = deleted.splice(-200).join(",");
}
var ruleNs = '#stream-item-tweet-';
$("head").append('<style>' + ruleNs + deleted.join(',' + ruleNs) + '{ display:none !important; }</style>');
ruleNs = '#stream-item-activity-';
$("head").append('<style>' + ruleNs + deleted.join(',' + ruleNs) + '{ display:none !important; }</style>');
var btn = '<li class="hide-stream"><a class="js-hide-tweet" data-hider-action="hide" href="#" data-nav="hide_tweet" title="Hide Tweet">Hide Tweet</a></li>';
$("body").on("mouseover", ".dropdown-toggle", function () {
var $tweet = $(this).closest(".js-stream-item");
$tweet.not(":has(.hide-stream)").find(".dropdown-menu ul").append(btn);
}).on('click', 'li a[data-hider-action]', function() {
var $tweet = $(this).closest(".js-stream-item");
$tweet.hide();
localStorage[ns] += $tweet.attr("data-item-id") + ",";
return false;
});
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment