Greasy Fork

Greasy Fork is available in English.

elecfans 电子发烧网 阅读全文

自动点击分页的全文按钮,并展开全文。去除部分广告。

当前为 2020-07-11 提交的版本,查看 最新版本

// ==UserScript==
// @name         elecfans 电子发烧网 阅读全文
// @namespace    http://tampermonkey.net/
// @version      0.16
// @description  自动点击分页的全文按钮,并展开全文。去除部分广告。
// @author       萱萱的饭
// @match        http://www.elecfans.com/*
// @match        http://m.elecfans.com/*
// @grant        none
// @note         20-07-11 0.16 新增 m.elecfans/* 的阅读全文、去除部分广告
// ==/UserScript==

(function() {
    'use strict';
    /* 该网站使用的是ajax判断用户是否登陆
如果未登录则缩起文章并添加上阅读全文按钮
*/
    $(document).ready(function(){

        //      这里判断 ajax后 未登录则缩起文章 改变css样式 若改变则还原
        //      电子说  http://www.elecfans.com/d/*
        var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;//浏览器兼容
        var config = { attributes: true, childList: true}//配置对象

        $("div.simditor-body").each(function(){
            var _this = $(this);
            var observer = new MutationObserver(function(mutations) {//构造函数回调
                mutations.forEach(function(record) {
                    if(record.type == "attributes"){//监听属性
                        //console.log("html的属性发生了变化");
                        $('div.simditor-body').css('height','100%');
                        $('.seeHide').remove();
                    }
                    if(record.type == 'childList'){//监听结构发生变化
                        //console.log("html的结构发生了变化")
                    }
                });
            });
            observer.observe(_this[0], config);
        });

        //      电子常识 http://www.elecfans.com/dianzichangshi/*
        //      点击阅读全文并展开
        $(".article-content").each(function(){
            var _this = $(this);
            var observer = new MutationObserver(function(mutations) {//构造函数回调
                mutations.forEach(function(record) {
                    if(record.type == "attributes"){//监听属性
                        //console.log("html的属性发生了变化");
                        $('.article-content').css('height','100%');
                        $('.seeHide').remove();
                    }
                    if(record.type == 'childList'){//监听结构发生变化
                        //console.log("html的结构发生了变化")
                    }
                });
            });
            observer.observe(_this[0], config);
        });

        $('.article-content').css('height','100%');
        $('.seeHide').remove();
        $('html body.article-page div#header div.advertising.clearfix').remove();
        $('a.page-next').each(function(i){if($(this).text()=='全文'){
            $(this)[0].click();
        }});
        //      去掉广告
        $('.sub-adbt').remove();


        // m.elecfans.com 展开全文
        var href= window.location.host;
        if("m.elecfans.com"==href){
            //展开
            $(".author_des").each(function(){
                var _this = $(this);
                var observer = new MutationObserver(function(mutations) {//构造函数回调
                    mutations.forEach(function(record) {
                        if(record.type == "attributes"){//监听属性
                            //console.log("html的属性发生了变化");
                            $("div.limit_height").removeClass("limit_height");
                            $(".open_app").remove();
                            $(".bottom_open_app").remove();
                            $('.see_more').remove();
                            $('.top_app_ad').remove();
                        }
                        if(record.type == 'childList'){//监听结构发生变化
                            //console.log("html的结构发生了变化")
                        }
                    });
                });
                observer.observe(_this[0], config);
            });
        }
    });
})();