Greasy Fork is available in English.

手机版移除知乎 App 下载

移除知乎 App 下载,自动取消下载提示

// ==UserScript==
// @name         手机版移除知乎 App 下载
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  移除知乎 App 下载,自动取消下载提示
// @author       sl00p
// @match        https://www.zhihu.com/*
// @grant        none
// @run-at       document-end
// ==/UserScript==

(function() {
    'use strict';
    let inter = setInterval(function() {
        let funList = ["Card DownloadGuide DownloadGuide-block", "DownloadGuide-inner",
                       "Card DownloadGuide DownloadGuide-block DownloadGuide-block--active", "Card ViewAllInappCard",
                       "OpenInAppButton OpenInApp is-shown", "Button Button--primary Button--blue", "Card TopstoryItem TopstoryItem--advertCard"];
        for(let idx = 0; idx < funList.length; ++idx) {
            let nodes = document.getElementsByClassName(funList[idx]);
            for(let jdx = 0; jdx < nodes.length; ++jdx) {
                if(nodes[jdx] !== undefined) {
                    nodes[jdx].remove();
                }
            }
        }
        if(window.location.href.indexOf("oia") > 0) {
            window.history.back()
        }
        let mainApp = document.getElementsByClassName("MobileAppHeader-downloadLink");
        for(let idx = 0; idx < mainApp.length; ++idx) {
            mainApp[idx].href = "";
            mainApp[idx].innerText = "不上知乎?";
        }
        let btnList = ["ModalWrap-itemBtn", "ModalButtonGroup ModalButtonGroup--horizontal"];
        for(let idx = 0; idx < btnList.length; ++idx) {
            let btn = document.getElementsByClassName(btnList[idx]);
            if(btn && btn.length > 1) {
                btn[1].click();
            }
        }
    }, 1000);
})();