【FSU】FIFA FUTWEB SBC任务操作增强器

FIFAFUT模式SBC任务便捷操作增强器👍👍👍,添加抄作业按钮(跳转futbin)、添加球员自动纠正为按能力高至低排序、添加球员俱乐部地区等信息搜索功能等...👍👍👍

La data de 20-08-2021. Vezi ultima versiune.

// ==UserScript==
// @name         【FSU】FIFA FUTWEB SBC任务操作增强器 
// @namespace    https://futcd.com/
// @version      0.1.1
// @description  FIFAFUT模式SBC任务便捷操作增强器👍👍👍,添加抄作业按钮(跳转futbin)、添加球员自动纠正为按能力高至低排序、添加球员俱乐部地区等信息搜索功能等...👍👍👍
// @author       Futcd_kcka
// @match        https://www.ea.com/fifa/ultimate-team/web-app/
// @icon         http://cdn.futcd.com/tm/tmicon.png
// @require		 https://cdn.bootcss.com/jquery/2.2.1/jquery.js
// @grant        GM_addStyle
// @grant        GM_log
// ==/UserScript==

(function() {
    'use strict';
    const futsbcup = {};
    futsbcup.keys = {
        title:{
            S:"UTSBCHubViewController",
            SC:"UTSBCChallengesViewController",
            SS:"UTSBCSquadSplitViewController",
            H:"UTHomeHubViewController",
            CS:"UTClubSearchFiltersView",
        },
        selector:{
            game:".ut-tab-bar-view.game-navigation",
            SC:".SBCChallenges",
            SCH:".expires.status",
            SS:".SquadPanel.SBCSquadPanel",
            SSH:".ut-squad-summary-info--right",
            copyButton:".FSU_copy-button",
            searchInput:".FSU_filter-input"
        },
        search:["club","nation","league"],
        sytle:".FSU_copy-button{background-color: #7e42f5;border-color: transparent;color: #29ffc9;padding-left: 1rem;padding-right: 1rem;line-height: 2rem; height: 2rem;font-size: 1rem; display: block; text-align: center; text-decoration: none;}.FSU_copy-button:hover{background-color: #a991f2;}.FSU_filter-input{border: 0;background-color: rgba(0,0,0,0) !important;padding-left: 0 !important;}",
        html:{
            copyButton:"<a href=\"https://www.futbin.com/squad-building-challenges/ALL/{sbcId}\" target=\"_blank\" class=\"FSU_copy-button\">抄作业</a>",
            searchInput:"<input type=\"text\" class=\"FSU_filter-input\" placeholder=\"{text}\" maxlength=\"50\">"
        }
    };
    futsbcup.copyButton = function(pageTitle,controller){
        var pageSeat,sbcId;
        if(pageTitle == this.keys.title.SC){
            pageSeat = this.keys.selector.SCH;
            sbcId = controller._set.id;
        }else if(pageTitle == this.keys.title.SS){
            pageSeat = this.keys.selector.SSH;
            sbcId = controller._challengeId + "/" + controller._set.name;
        }
        $(pageSeat).after(this.keys.html.copyButton.replace("{sbcId}",sbcId))
    };
    futsbcup.searchInput = function(controller){
        for(var i=0;i<this.keys.search.length;i++){
            var searchSeat = controller._filterContainer.searchFilters._collection[this.keys.search[i]].__label;
            var searchLabelText = $(searchSeat).text();
            $(searchSeat).html(this.keys.html.searchInput.replace("{text}",searchLabelText))
        }
        $(this.keys.selector.searchInput).bind('input propertychange', function() {
            var targetObject = $(this).parents(".ut-search-filter-control--row").prev("ul.inline-list");
            var targetPanel = targetObject.parent(".inline-container");
            targetObject.css("height","14rem").css("background-color","#171826")
            targetObject.children("li").show();
            if($(this).val().length > 0){
                if(targetObject.children("li:contains('" + $(this).val() + "')").length > 0){
                    targetObject.children("li:not(:contains('" + $(this).val() + "'))").hide();
                }
            }
        });
    };
    futsbcup.callBack = function(){
        if($(futsbcup.keys.selector.game).length === 0) return;
        var controller = getAppMain().getRootViewController().getPresentedViewController().getCurrentViewController().getCurrentController();
        if(!controller || !controller.className) return;
        if(controller.className == futsbcup.keys.title.SC || controller.className == futsbcup.keys.title.SS){
            if($(futsbcup.keys.selector.copyButton).length === 0){
                futsbcup.copyButton(controller.className,controller);
            }
        };
        if(controller.className == futsbcup.keys.title.SS){
            var rightController = controller._rightController._currentController.getView();
            if(rightController.className == futsbcup.keys.title.CS){
                if(rightController.getSortDropDown().getId() === 0){
                    rightController.getSortDropDown().setIndexById(2)
                }
                if($(futsbcup.keys.selector.searchInput).length === 0){
                    futsbcup.searchInput(rightController);
                }
            }            
        };
    };
    futsbcup.start = function(){
        GM_addStyle(this.keys.sytle);
        //选择一个需要观察的节点
        var targetNode = $(document)[0],
        // 设置observer的配置选项
            config = {childList: true,characterData: true,attributes: false,subtree: true},
            observer = new MutationObserver(this.callBack);
        //使用配置文件对目标节点进行观测
        observer.observe(targetNode, config);
    };
    GM_log("**加载插件成功**")
    futsbcup.start()
})();