Tumblr Remove Recommended

Tumblrのダッシュボードに挿入されるおすすめを消す

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Tumblr Remove Recommended
// @namespace    https://greasyfork.org/ja/users/19495-kakkou
// @version      0.1
// @description  Tumblrのダッシュボードに挿入されるおすすめを消す
// @author       kakkou
// @match        https://www.tumblr.com/dashboard
// @grant        none
// ==/UserScript==

function deleteNode(node) {
    if ( node.nodeName == "LI" && node.getAttribute("class") == "post_container" ) {
        var div = node.childNodes[0]; //div
        if ( div.getAttribute("data-is_recommended") ) {
            node.parentNode.removeChild(node);
            return 1;
        }
    }
    return 0;
}

// 最初から読まれてる奴を消す
var elements = document.getElementsByClassName("post_container");
var index = 0;
while(index < elements.length) {
    if ( deleteNode(elements[index]) == 0 ) {
        ++index;
    }
}

// 動的にロードされる奴を消す
document.addEventListener("DOMNodeInserted", function(e){
    deleteNode(e.target);
});