极简 It之家新闻列表

仅保留新闻列表

目前为 2021-05-13 提交的版本。查看 最新版本

// ==UserScript==
// @name         极简 It之家新闻列表
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  仅保留新闻列表
// @author       You
// @match        *://*.ithome.com/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    var currentURL = window.location.href;
    var newsList = /list/;

    // 如果是新闻列表
    if (newsList.test(currentURL)) {
        // 新闻列表页
        $("body").html(`<div style="width:720px;margin:0 auto;">${$("#list").find("div.fl").html()}</div>`)

        $("li a[class='t']").each(function () {
            $(this).css("width","450px");
            if ($(this).prop("href").indexOf("lapin") > -1) {
                $(this).parent().remove();
            }
        })
    } else {
        // 内容页面
        $("#dt").siblings().remove();

        $("#dt>div:eq(1)").remove();

        $("#dt .fl").css("width", "auto");

        $("#dt .fl>script").remove();

        $("#dt .fl .shareto").remove();

        $("#dt .fl .related_post").remove();

        $("#dt .fl iframe:first").remove();

        $("img").each(function () {
            $(this).prop("src", $(this).data("original"))
        });
        
    }
})();