maddawgjav.net排版脚本

maddawgjav.net网站重新排版,浏览图片内容更方便,你懂的

当前为 2016-01-02 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         maddawgjav.net排版脚本
// @namespace    http://greasyfork.org/zh-CN/users/25794
// @version      0.1
// @description  maddawgjav.net网站重新排版,浏览图片内容更方便,你懂的
// @author       Hobby
// @require      http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.4.min.js
// @include      http://www.imagebam.com/image/*?url=maddawgjav.net
// @match        http://maddawgjav.net/*
// @grant        none

// 交流QQ群:273406036 
// 内地用户推荐Chrome + XX-Net(代理) + Proxy SwitchyOmega(扩展)的环境下配合使用。
// V1.0.0 针对maddawgjav.net网站的支持,支持方便浏览图片

// ==/UserScript==
/* jshint -W097 */
'use strict';
function addJQuery(callback) {
    var script = document.createElement("script");
    script.setAttribute("src", "http://ajax.microsoft.com/ajax/jquery/jquery-2.1.4.min.js");
    script.addEventListener('load', function() {
        var script = document.createElement("script");
        script.textContent = "(" + callback.toString() + ")();";
        //debugger;
        document.body.appendChild(script);
    }, false);
    document.body.appendChild(script);
}

// 执行函数的入口
function main() {
    // 获取全域名
    function getHostName(url) {
        var e = new RegExp('^(?:(?:https?|ftp):)/*(?:[^@]+@)?([^:/#]+)'), matches = e.exec(url);
        return matches ? matches[1] : url;
    }
    // 获取后缀域名
    function getLastName(webName) {
        var array = webName.split(".");
        if(array.length === 3){
            var a = webName.indexOf('.');
            var lastName = webName.substring(a + 1, webName.length);
            return lastName;
        }
        else if(array.length === 2){
            return webName;
        }
    }

    function urlfilename(a) {
        var n1 = a.lastIndexOf('/') + 1;
        var n2 = a.lastIndexOf('.');
        a = a.substring(n1, n2);
        return a;
    }

    function urljpgid(a) {
        var n1 = a.lastIndexOf('/');
        var n2 = a.lastIndexOf('/')-9;
        a = a.substring(n1, n2);
        return a;
    }

    var location = document.location;

    //子级iframe判断是否约定的Url
    if(typeof(location)!== "undefined" && location.href.indexOf('?url=maddawgjav.net') > -1){

        var jpg_id = urljpgid(location.pathname);
        var $jpg_id = $("#i"+jpg_id);
        var img_src = $jpg_id.attr("src");
        var img_pEle = $jpg_id[0].parentElement;
        //$jpg_id.remove();
        //debugger;
        $jpg_id.attr("src","http://maddawgjav.net/wp-content/themes/zbench.1.2.3/zbench/images/search-input-bg.gif");

        var $iframe = $(document.createElement("IFRAME"));  
        $iframe.attr("width", "0");  
        $iframe.attr("height", "0");
        //将问号后的.转换成%%  然后载入iframe的地址
        $iframe.attr("src", "http://maddawgjav.net/wp-login.php?"+img_src.replace(/\./g,"%%"));

        $(img_pEle).append($iframe);
    }
    //子级iframe的子级iframe判断是否约定的Url
    else if(typeof(location)!== "undefined" && location.href.indexOf('maddawgjav.net/wp-login.php') > -1){
        var jpg_id = urljpgid(location.search);
        var av_cd =$('#href'+jpg_id, window.parent.parent.document).get(0).parentElement.avcd;
        var av_name = $('#href'+jpg_id, window.parent.parent.document).get(0).parentElement.av_name;
        var href = location.search.substring(1,location.search.length).replace(/\%\%/g,".");
        $('#img'+jpg_id, window.parent.parent.document).attr("src",href );//"http://imagetwist.com/error.jpg?" +  + '??$@' + av_cd + "?$@" + av_name

        var $hobbyimgN = $($('#href'+jpg_id, window.parent.parent.document).get(0).firstElementChild);
        //debugger;
        //$hobbyimgN.src = href;
        $iframe = $('#iframe'+jpg_id, window.parent.parent.document);
        $iframe.attr("src", "");//释放资源
        //$iframe.attr("src", "http://maddawgjav.net/wp-content/themes/zbench.1.2.3/zbench/images/search-input-bg.gif?" + href);        
    }
    else{
        //debugger;
        $("#sidebar-border").insertBefore("#content");
        $("#wrapper").css('margin','0');
        $("#wrapper").css('width','100%');
        $("#wrapper").css('width','initial');
        $("#sidebar-border").css('position','absolute');
        $("#content").css('margin-left','300px');
        $("#content").css('width','initial');

        //帖子第一张主题图片
        var img_t_array = $("img[class='alignnone']");
        //帖子的第一张缩略图删除
        for (var index = 0; index < img_t_array.length; index++) {
            var img_t = img_t_array[index];
            //debugger;
            //主题图片靠左排版
            $(img_t).css('float','left');
            //帖子的第一张缩略图删除
            $(img_t.nextElementSibling.nextElementSibling).remove();
        }

        //所有div帖子
        var div_tz_array = $("div[id^='post-']");
        for (var index = 0; index < div_tz_array.length; index++) {
            var div = div_tz_array[index];
            $(div).css('width','initial');
        }


        //所有p标签的文字
        var p_tz_array = $("p[style='text-align: center;']");
        for (var index = 0; index < p_tz_array.length; index++) {
            var p = p_tz_array[index];
            $(p).css('text-align','left');
        }


        var img_array = $("img[alt='imagebam.com']");
        for (var index = 0; index < img_array.length; index++) {
            //TODO:foreach:2
            var img = img_array[index];
            var web_name = getHostName(img.src);
            var lastName = getLastName(web_name);
            //debugger;
            $(img).css("width","100px");
            //图片靠左排版
            $(img).css('float','left');
            //备份width
            img.name = "100";

            if (lastName === 'imagebam.com') {
                //TODO:javbest:imagebam.com
                var jpg_name = urlfilename(img.src);
                var jpg_id = jpg_name.substring(jpg_name.length-9,jpg_name.length);
                var url = 'http://www.imagebam.com/image/' + jpg_name ;// + "??$@" + av_cd + "?$@" + av_name
                img.parentElement.href = url;
                img.parentElement.id = "href"+ jpg_id;
                img.id = "img"+ jpg_id;

                $(img.parentElement).removeAttr("href");
                $(img.parentElement).click( function () {
                    //debugger;
                    if(this.firstChild.style.width !== ''){
                        $(this.firstChild).css("max-width","none"); 
                        $(this.firstChild).css('width','');
                    }
                    else{
                        //$(this.firstChild).css("max-width","");
                        $(this.firstChild).css('width', this.firstChild.name);
                    }
                });

                var $iframe = $(document.createElement("IFRAME"));  
                $iframe.attr("id","iframe"+jpg_id);
                $iframe.attr("frameborder", 1);  
                //$iframe.attr("scrolling", undefined === scrolling ? "no" : scrolling);  
                $iframe.attr("width", "220");  
                $iframe.attr("height", "420");
                $iframe.attr("src", 'http://www.imagebam.com/image/' + jpg_name + "/?url=maddawgjav.net");

                //debugger;
                $(img.parentElement).append($iframe);

                var $br = $(document.createElement('br'));
                $(img.parentElement).append($br);
                $(img).css("vertical-align","top");
            }
        }        
    }
    //图片的完全加载完才执行的图片宽度设置
    /**document.addEventListener("DOMContentLoaded",function(){
        var img_array = $("img[alt='imagebam.com']");
        for (var index = 0; index < img_array.length; index++) {
            var img = img_array[index];
            //debugger;
            $(img).css("width",img.width);
            //备份width
            img.name = img.width;
        }
    });**/
}

// load jQuery and execute the main function
addJQuery(main);