oneindex辅助

try to take over the world!

目前为 2018-11-04 提交的版本。查看 最新版本

// ==UserScript==
// @name         oneindex辅助
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       wangwangyang
// @match        https://sleazyfork.org/zh-CN/scripts/26927-222%E5%8F%B7%E5%B7%B4%E5%A3%AB%E9%80%9A%E7%A5%A8/code
// @grant        none
// @require      http://cdn.bootcss.com/jquery/2.1.4/jquery.min.js
// @include      *://*/*
// ==/UserScript==

(function() {
    'use strict';
    if ($('body').hasClass('mdui-theme-primary-blue-grey')) {
        var ls = window.localStorage;
        $('.mdui-theme-accent-blue .mdui-color-theme-accent').attr('href', 'javascript:;');
        $('.mdui-theme-accent-blue .mdui-color-theme-accent').click(function() {
            thumbb();
        });
        $('.mdui-list .file  a').each(function() {
            var href = $(this).attr('href');
            if (typeof(href) != 'undefined') {
                //console.info(href);
                if ($(this).find('i').text() == 'ondemand_video') {
                    var key = $(this).find('span').text();
                    if (ls[key] != null) {
                        $(this).css("backgroundColor", "#f0f0ff");
                    }
                    var loc = window.location.href;
                    var xy = loc.substring(0, loc.indexOf('://') + 3);
                    var host = loc.substring(xy.length, loc.length);
                    host = host.substring(0, host.indexOf('/'));
                    loc = xy + host;
                    //console.info(loc);
                    //            href='oneindex://'+loc+href;
                    href = 'potplayer://' + loc + href;
                    $(this).attr('href', 'javascript:;');
                    $(this).attr('url', href);
                    $(this).attr('target', '_self');
                    //console.info(href);
                    $(this).click(function() {
                        var url = $(this).attr('url');
                        console.info(url);
                        $(this).css("backgroundColor", "#f0f0ff");
                        var key = $(this).find('span').text();
                        ls.setItem(key, url);
                        console.info($(this).find('span').text());
                        window.location.href = url;
                    })
                }
            }
        });

        function thumbb() {
            if ($('.mdui-fab i').text() == "apps") {
                $('.mdui-fab i').text("format_list_bulleted");
                $('.nexmoe-item').removeClass('thumb');
                $('.nexmoe-item .mdui-icon').show();
                $('.nexmoe-item .mdui-list-item').css("background", "");
            } else {
                $('.mdui-fab i').text("apps");
                $('.mdui-col-xs-12 i.mdui-icon').each(function() {
                    if ($(this).text() == "image" || $(this).text() == "ondemand_video") {
                        var href = $(this).parent().parent().attr('href');
                        var thumb = (href.indexOf('?') == -1) ? '?t=220': '&t=220';
                        //$('.nexmoe-item').remove();
                        //$('body').append('<img src=\"'+href+'\" style=\"width:100%;\">');
                        $(this).parent().parent().html('<img src=\"' + href + '\" style=\"width:100%;\">');
                        $(this).hide();
                    }
                });
            }

        }

    }
})();