屏蔽知乎视频

屏蔽网页版知乎时间线上的视频。Remove video in Zhihu timeline.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         屏蔽知乎视频
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  屏蔽网页版知乎时间线上的视频。Remove video in Zhihu timeline.
// @author       Max
// @match        https://www.zhihu.com/
// @grant        Max
// ==/UserScript==

function removeVideo(){
    var p = document.getElementsByClassName("ContentItem ZVideoItem");
    Array.prototype.slice.call(p).forEach(function(item){
        item.remove();
    })
}
removeVideo();
var timeline = document.getElementById("TopstoryContent");
var config = { attributes: true, childList: true, subtree: true };
var callback = function(mutationsList) {
    mutationsList.forEach(function(item,index){
        if (item.type == 'childList') {
            if(item.target.innerHTML.indexOf("zvideo")!=-1){
                removeVideo();
            }
        }
    });
}
var observer = new MutationObserver(callback);
observer.observe(timeline, config);