// ==UserScript== // @name IT之家清爽文章阅读 // @namespace http://tampermonkey.net/ // @version 0.1 // @description 只保留标题、文章、打分和评论 // @author Bingnme // @license MIT // @match https://www.ithome.com/0/* // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; // 你的代码在这里... var dt = document.getElementById("dt"); // 获取 id="dt" 的元素 var paragraph = document.getElementById("paragraph"); // 获取 id="paragraph" 的元素 var post_comm = document.getElementById("post_comm"); // 获取 id="post_comm" 的元素 var newsgrade = document.getElementsByClassName("newsgrade")[0];//获取 class="newsgrade" 的元素 var body = document.body; // 获取 body 元素 var firstdiv = dt.children[0];//获取 dt 里面第1个元素 var title = firstdiv.children[1];//获取 firstdiv 里面第2个元素 body.innerHTML = ""; // 清空 body 的内容 body.style.marginTop = "3px"; // 添加这一行来把 body 的上边距调整为 3px body.style.padding = "0";//把 body 的填充设置为0 body.appendChild(dt); // 把 dt 元素添加到 body 中 dt.removeChild(dt.children[1]); // 添加这一行来把 dt 所在的 div 里的第2个 div 清除 firstdiv.innerHTML = "";// 清空 firstdiv 的内容 firstdiv.appendChild(title);//把 title 元素添加到 firstdiv 中 firstdiv.appendChild(paragraph);//把 paragraph 元素添加到 firstdiv 中 firstdiv.appendChild(newsgrade);//把 newsgrade 元素添加到 firstdiv 中 firstdiv.appendChild(post_comm);//把 post_comm 元素添加到 firstdiv 中 })();