O Antagonista - Speed Read

Fast reading of the micro blog!

当前为 2016-06-07 提交的版本,查看 最新版本

// ==UserScript==
// @name         O Antagonista - Speed Read
// @namespace    http://oantagonista.com/speedread
// @version      0.1.0
// @description  Fast reading of the micro blog!
// @author       ViZeke
// @match        http://www.oantagonista.com/
// @match        http://www.oantagonista.com/pagina/*
// @grant        none
// @require      https://code.jquery.com/jquery-2.1.4.min.js
// ==/UserScript==

(function($) {
    'use strict';

    function addGlobalStyle(css) {
        var head, style;
        head = document.getElementsByTagName('head')[0];
        if (!head) { return; }
        style = document.createElement('style');
        style.type = 'text/css';
        style.innerHTML = css;
        head.appendChild(style);
    }

    function procArticles($articles){
        var baseUrlPosts = 'http://www.oantagonista.com';

        $articles.each(function(i, itemPost) {
            var url = baseUrlPosts + $(itemPost).first().find('a').first().attr('href');

            $.get(url)
                .success(function(response) {

                var $content = $(response).find('div.l-main-right').first().find('p');
                var actualContent = [];

                $content.each(function(j, itemP){
                    if ($(itemP).attr('class') === undefined){
                        actualContent.push(itemP);
                    }
                });

                $(itemPost).attr('processed', 1);
                $(itemPost).find('p').remove();
                $(itemPost).find('.post-more').remove();
                $(itemPost).find('.post-summary').append(actualContent);
            });
        });
    }

    function cleanAds(){
        $('div.banner').remove();
        $('aside').remove();
        $('ins').remove();
    }

    var procArticle = true;
    var procClean = true;

    $(document).scroll(function(){
        if (procArticle){
            setTimeout(function(){
                procArticles($('article.post[processed!=1]'));
                procArticle = true;
            }, 1000);
        }
        if (procClean){
            setTimeout(function(){
                cleanAds();
                procClean = true;
            }, 2000);
        }
        procArticle = false;
        procClean = false;
    });

    //Init
    addGlobalStyle('div.post-summary { width: auto; }');
    addGlobalStyle('article.post.first-post { margin-top: 25px; }');

    cleanAds();
    procArticles($('article.post[processed!=1]'));

})(jQuery);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址