首页 » 工作 » 方法 » 正文

油猴 Tampermonkey 脚本整理

发布者:某某人
2018/12/7 浏览数(88) 分类:方法 暂无评论

隐藏置顶贴(深度论坛)

// ==UserScript==
// @name         隐藏置顶贴(深度论坛)
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://bbs.deepin.org/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    jQuery("tbody[id^='stickthread_'").remove();
})();

记住ReactNative文档中左侧导航的滚动位置/h2>

// ==UserScript==
// @name         记住ReactNative文档中左侧导航的滚动位置
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  记住RN官网和中文网文档页面中左侧边栏里导航的滚动位置
// @author       You
// @match        https://reactnative.cn/docs/*
// @match        https://facebook.github.io/react-native/docs/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
    var nav = document.querySelector('#docsNav');
    // 滚动到上次的位置
    nav.scrollTop = localStorage.navScrollTop || 0;
    // 记录这次的位置
    nav.addEventListener('scroll', function(){
        localStorage.navScrollTop = nav.scrollTop;
    });
})();

技术博客自动阅读视图

// ==UserScript==
// @name         技术博客自动阅读视图
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  CSDN、简书、51CTO、博客园、MTK FAE、开源中国、segmentfault.com、掘金、新浪博客自动点击Flash弹窗
// @author       inmyfree
// @match        *://blog.csdn.net/*
// @match        *://www.cnblogs.com/*
// @match        *://www.jianshu.com/p/*
// @match        *://blog.51cto.com/*
// @match        *://segmentfault.com/a/*
// @match        *://juejin.im/*
// @match        *://blog.sina.com.cn/*
// @match        *://my.oschina.net/*
// @match        *://online.mediatek.com/FAQ#/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    var webSiteUrl = window.location.href;
    if(webSiteUrl.indexOf("blog.csdn.net") >= 0 ) { //CSDN V3
        $(".pulllog-box").css("display","none");
//        $(".read_more_btn").click();
//        $("#btn-readmore").click();

        $(".hide-article-box").css("display","none");
        $("#article_content").css("height","unset");
        $("#article_content").css("overflow","unset");
        $("#article_content").css("overflow","unset");

        var elementClassID = ["svg","aside",".related-article",".t0",".p4course_target","#adt0",".article-type",".article-bar-top",".article-bar-bottom",".article-bar-bottom",".edu-promotion",".mask-dark",".pulllog-box",".recommend-box",".comment-box",".tool-box",".box-box-large",".box-box-default",".meau-gotop-box",".article-info-box",".report-box",".advert-bg",".advert-cur","#csdn-toolbar","#commentBox","#loginWrap","#MathJax_Message"];
        $.each(elementClassID,function(index,value){$(value).remove();});
        var style = document.createElement('style');
        style.innerHTML = "\
            @media screen and (max-width:1200px) {\
                .container, .pulllog {width: auto;}\
                .container main, .pulllog main {width: auto;}\
            }\
            @media screen and (min-width:1201px) {\
                .container, .pulllog {width: auto;}\
                .container main, .pulllog main {width: auto;}\
            }\
            main { max-width: 950px; min-width: unset; margin: 0 auto; float: none;}\
            body { min-width: unset;background: unset;}\
            .recommend-right, .fourth_column {display:none;}\
            @media screen and (max-width: 1200px) .container, .pulllog { width: unset;}\
            @media screen and (max-width: 1320px) .container, .pulllog { width: unset;}\
            @media screen and (max-width: 1200px) .container main, .pulllog main { width: unset;}\
            @media screen and (max-width: 1320px) .container main, .pulllog main { width: unset;}\
            main {margin-bottom: unset;} ";
        window.document.head.appendChild(style);
        document.getElementsByTagName("header")[0].remove();
        document.getElementsByTagName("aside")[0].remove();
    }else if(webSiteUrl.indexOf("www.cnblogs.com") >= 0 ){ //博客园V3
        elementClassID = ["#leftcontent","#mytopmenu","#page_begin_html",".footer","#header","#blog_post_info_block",".postDesc","#comment_nav","#under_post_news","#cnblogs_c2","#under_post_kb","#sideBarMain","#comment_form_container","#footer","#blog-comments-placeholder","#comment_form","#sideBar"];
        $.each(elementClassID,function(index,value){ $(value).remove();});
        style = document.createElement('style');
        style.innerHTML = "body {background: unset;}\
            .hui-t5 .hui-main .hui-b {margin-right: 3px;}\
            #rightmenu {display: none;}\
            #centercontent {padding-left: 20px;}\
            #main { position: initial; max-width: 950px; min-width: unset; width: unset; margin: 30px auto;}\
            #mainContent {width: unset;float: unset;}\
            #home {background-image: unset;}";
        window.document.head.appendChild(style);
    }else if(webSiteUrl.indexOf("www.jianshu.com") >= 0 ){ //简书
        elementClassID = [".new-comment",".navbar-fixed-top","#free-reward-panel",".follow-detail",".show-foot",".author",".meta-bottom","#web-note-ad-1","#comment-list","#web-note-ad-fixed",".side-tool",".note-bottom"];
        $.each(elementClassID,function(index,value){ $(value).remove();});
        style = document.createElement('style');
        style.innerHTML = "body {padding-top: 1px!important;} .note {padding-top: 1px;} .note .post {margin: 0 auto; padding-top: 1px; padding-bottom: 1px; width: auto; padding-left: 10px;padding-right: 10px;} .note .post .article .show-content .image-package {width:unset;margin-left:unset;}";
        window.document.head.appendChild(style);
    }else if(webSiteUrl.indexOf("blog.51cto.com") >= 0 ){ //51CTO
        elementClassID = [".Header",".Right",".artical-Right",".Footer",".rightTools",".crumbs",".artical-other-title",".artical-title-list",".artical-border","#comment",".artical-copyright",".for-tag",".more-list",".artical-list"];
        $.each(elementClassID,function(index,value){ $(value).remove();});
        style = document.createElement('style');
        style.innerHTML = ".Page {width:auto; margin: 0 auto;}	.Left, .fl {width: -webkit-fill-available;margin: 0 20px;} .artical-title {margin-top: 10px; font-size: 28px; line-height: 1.5; font-weight: normal;} .artical-Left {width:auto;padding: 24px; padding-top: 1px; background: #fff; word-break: break-all;} ";
        window.document.head.appendChild(style);
    }else if(webSiteUrl.indexOf("segmentfault.com") >= 0 ){ //segmentfault.com
        elementClassID = [".comments--news",".breadcrumb","#goToReplyEditor","#paradigm-article-related",".mt10",".pt20",".col-md-3",".post-nav",".hidden-md",".content__tech",".article__author","meta",".global-nav","#icon4weChat","#gridMapHoverBox","#articleId","#shareToWeiboModal",".widget-911","#loginBanner","#footer","#fixedTools","#loginModal","#registerModal","#phoneLoginModal","#bindPhoneModal","#noteWidget","#atwho-container","#p_analyse_iframe"];
        $.each(elementClassID,function(index,value){ $(value).remove();});
        style = document.createElement('style');
        style.innerHTML = ".col-md-9 {width: 100%;} .fmt pre {max-height: unset;} .article__content {margin-top: 0px;} .container{width: 98%;}";
        window.document.head.appendChild(style);
    }else if(webSiteUrl.indexOf("juejin.im") >= 0 ){ //掘金 juejin.im
        elementClassID = ['div[itemprop|="author"]', 'div[itemprop|="publisher"]', ".footer", ".banner", ".entry-public-info", ".originalUrl", "meta",".entry-public-aside",".main-header-box",".mobile-bottom-bar",".author-info-block", ".article-banner",".tag-list-box",".books-recommend",".sidebar",".article-suspended-panel", ".comment-box", ".recommended-area", ".suspension-panel", ".global-component-box" ];
        $.each(elementClassID,function(index,value){ $(value).remove();});
        style = document.createElement('style');
        style.innerHTML = ".container { max-width: unset;} .main-area[data-v-13f76525] { width: unset;} .column-view[data-v-13f76525] {padding: 0 0 0;} .main-container>.view[data-v-3f216172] {margin-top: 0;} .entry-public-view .entry-public-main[data-v-41d33d72] { max-width: unset;} .entry-public-main .shadow{padding-top: 20px; padding-bottom: 0px;}";
        window.document.head.appendChild(style);
    }else if(webSiteUrl.indexOf("my.oschina.net") >= 0 ){ //开源中国
        elementClassID = ["x-foo-define","val","#headerNavMenu",".secondary",".two", ".dimmer",".mini",".left",".right",".label", ".breadcrumb",".blog-meta",".reward-list",".author-card","#commentsContainer",".article-list","#footer","#copyright",".back-to-top",".action",".ad-wrap",];
        $.each(elementClassID,function(index,value){ $(value).remove();});
        style = document.createElement('style');
        style.innerHTML = "#mainScreen { padding-top: 14px;} .body-container{width: 100%!important;padding-top: 0!important; padding-bottom: 1rem!important;padding-left: 1rem!important; padding-right: 1rem!important;} ";
        window.document.head.appendChild(style);
    }else if(webSiteUrl.indexOf("online.mediatek.com") >= 0 ){ //MTK
        elementClassID = ["#faqfilter","#masterTop",".col-md-3",".container-fluid",".footer",
                          ".minWidth","#mainContent","#pdfdownload",".aspNetHidden","#imgPrefetch",
                          "#mtk__browser__alert",".s4-notdlg","#TurnOffAccessibility","#TurnOnAccessibility",
                          "#TurnOffAnimation","#TurnOnAnimation","#notificationArea","#DeltaPageStatusBar","#s4-ribbonrow","#faqPrefBar",,"#divWarning","#DeltaFormDigest","#DeltaPlaceHolderUtilityContent",'div[ng-show|="detail.Type===10"]'];
        $.each(elementClassID,function(index,value){ $(value).remove();}); $('div[ng-show|="detail.Type===10"]').remove();
        style = document.createElement('style');
        style.innerHTML = ".row {margin-right: 0px;margin-left: 0px;} .col-md-9 { width: auto; float: none;} .content-div {border: none;}";
        window.document.head.appendChild(style);
    }else if(webSiteUrl.indexOf("blog.sina.com.cn") >= 0 ){ //新浪博客自动点击Flash弹窗
        document.getElementById("_"+document.getElementsByClassName("CP_w")[1].id.split("_")[1]+"_btnClose").click();
    }
})();

CSDN自动展开+去广告+净化剪贴板+免登陆

// ==UserScript==
// @name         CSDN自动展开+去广告+净化剪贴板+免登陆
// @namespace    http://tampermonkey.net/
// @version      1.2.8
// @description  ITeye CSDN自动展开阅读,可以将剪贴板的推广信息去除,去除大多数广告。
// @author       gorgias
// @match        *://blog.csdn.net/*/article/details/*
// @match        *://bbs.csdn.net/topics/*
// @match        *://*.iteye.com/blog/*
// @grant        none
// @icon         https://csdnimg.cn/public/favicon.ico
// @run-at       document-end
// ==/UserScript==

// 根据网速自己设置时间间隔
var interval = 3000;
var sideInterval = 4000;
var bbsInterval = 3000; // 在ADBlock之后运行
var iteyeInterval = 100;

(function () {
    'use strict';
    var currentURL = window.location.href;
    var blog = /article/;
    var bbs = /topics/;
    var iteye = /iteye/;
    //若为CSDN论坛,则:
    if(bbs.test(currentURL)){
        setTimeout(function () {
            $(".js_show_topic").click();
            document.getElementsByClassName("pulllog-box")[0].remove(); // 底部广告
            $(".mediav_ad").remove();       // 帖子尾部广告
            $(".post_recommend").remove();  // 帖子内[CSDN推荐]
        }, bbsInterval);
    }else if (blog.test(currentURL)){
        if (document.getElementById("btn-readmore")){
            document.getElementById("btn-readmore").click();
            localStorage.setItem("anonymousUserLimit", "");
        } //自动展开
        csdn.copyright.init("", "", ""); //去除剪贴板劫持
        setTimeout(function () {
            document.getElementsByClassName("csdn-tracking-statistics mb8 box-shadow")[0].remove(); //左上广告
            document.getElementById("asideFooter").remove();
            document.getElementById("adContent").remove();
            document.getElementsByClassName("p4course_target")[0].remove();
            document.getElementsByClassName("bdsharebuttonbox")[0].remove();
            document.getElementsByClassName("vip-caise")[0].remove();
        }, interval);
        setTimeout(function () {
            $("div[id^='dmp_ad']")[0].remove();
            document.getElementsByClassName("fourth_column")[0].remove();
        }, sideInterval);
        setTimeout(function () {
            document.getElementsByClassName("pulllog-box")[0].remove(); // 底部广告
            var recommendObj = document.getElementsByClassName("recommend-fixed-box")[0].getElementsByClassName("right-item");
            for (var h = (recommendObj.length - 1); h>=0; h--) {
                if (recommendObj[h].tagName == "DIV") {
                    recommendObj[h].remove();
                }
            }
            document.getElementsByClassName("p4course_target")[0].remove();
        }, sideInterval);
        setTimeout(function () {
            var hot = document.getElementsByClassName("type_hot_word");
            var recommend = document.getElementsByClassName("recommend-ad-box");
            for (var i = (hot.length - 1); i >= 0; i--) {
                hot[i].remove();
            }
            for (var j = (recommend.length - 1); j >= 0; j--) {
                recommend[j].remove();
            }
            document.getElementsByClassName("fourth_column")[0].remove();
        }, sideInterval);
        setTimeout(function () {
            document.getElementsByClassName("right-item _paradigm_S8_csdn_ads_render")[0].remove(); //右侧广告
            document.getElementsByClassName("right-item _paradigm_S27_csdn_ads_render")[0].remove();
            document.getElementById("kp_box_476").remove();
        }, 5000);
    } else if (iteye.test(currentURL)) {
        setInterval(function(){
            document.getElementById('btn-readmore').click();
        }, iteyeInterval);
        setTimeout(function () {
            document.getElementsByClassName("blog-sidebar")[0].remove();
            document.getElementById('main').style.width = '1000px';
        }, sideInterval);
    }
})();

暂时木有评论啊,等您坐沙发呢!

发表评论

点击返回顶部
  1. 留言
  2. 联系方式