// ==UserScript== // @name 【FSU】FIFA FUTWEB SBC任务操作增强器 // @namespace https://futcd.com/ // @version 0.1.4 // @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 // @grant GM_openInTab // @grant GM_getValue // @grant GM_setValue // @license MIT // @downloadURL none // ==/UserScript== (function() { 'use strict'; window.requirementTarget = ""; const futsbcup = {}; futsbcup.keys = { title:{ S:"UTSBCHubViewController", SC:"UTSBCChallengesViewController", SSS:"UTSBCSquadSplitViewController", H:"UTHomeHubViewController", CS:"UTClubSearchFiltersView", MF:"UTMarketSearchFiltersView", CSR:"UTClubSearchResultsView", ID:"UTItemDetailsView", SS:"UTSquadSplitViewController", }, selector:{ game:".ut-tab-bar-view.game-navigation", SC:".SBCChallenges", SCH:".sbc-status-container div.expiry", SS:".SquadPanel.SBCSquadPanel", SSH:".ut-squad-summary-info--right", copyButton:".FSU_copy-button", searchInput:".FSU_filter-input", positionButton:".FSU_position-button", }, requirements:["球隊評分最低為:","Min. Team Rating:","最低球队评分:"], search:["club","nation","league"], sytle:".FSU_copy-button,.FSU_count-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 !important;background-color: rgba(0,0,0,0) !important;padding-left: 0 !important;}.FSU_count-button{background-color: #1a96f6;color: #f2f2f2;}.FSU_count-button:hover{background-color: #45a9f7;}.FSU_position-button{font-family:UltimateTeam-Icons,sans-serif;font-style:normal;font-variant:normal;font-weight:400;text-transform:none;color:#c4f750;width:4rem;height:4rem;flex-shrink:0;font-size:1.6em;display:flex;text-decoration:none;text-align:center;justify-content:center;align-items:center;position:absolute;right:3rem;z-index:0;top:0;}.FSU_position-button::before{content:'\\E060';}.FSU_position-button:hover{color:#f2f2f2 !important;}", html:{ copyButton:"作业", countButton:"计算", searchInput:"", positionButton:"" }, setSrot:false, positionInitial:-2, positionExchange:{2:[3,8,12,23,130,2],3:[2,7,5,12,130,3],5:[130,10,3,7,5],7:[8,3,5,16,130,7],8:[7,2,16,27,130,8],10:[14,18,5,131,10],12:[23,20,16,2,3,14,131,12],14:[10,18,12,16,131,14],16:[27,22,12,8,7,14,131,16],18:[21,14,10,131,18],20:[23,12,22,25,21,132,20],21:[18,25,20,22,132,21],22:[27,16,20,25,21,132,22],23:[12,20,27,2,132,23],25:[21,20,22,132,25],27:[16,22,23,8,132,27]}, }; 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.SSS){ pageSeat = this.keys.selector.SSH; sbcId = controller._challengeId + "/" + controller._set.name; var requirementsText = ""; var requirementsWait = setInterval(function(){ requirementsText = controller._requirementsNotification.getView()._requirements.__requirements.getInnerHTML(); if(requirementsText != ""){ clearInterval(requirementsWait) for (let index = 0; index < futsbcup.keys.requirements.length; index++) { GM_log(futsbcup.keys.requirements[index]) if(requirementsText.indexOf(futsbcup.keys.requirements[index]) != -1){ window.requirementTarget = parseInt(requirementsText.substr(requirementsText.indexOf(futsbcup.keys.requirements[index]) + futsbcup.keys.requirements[index].length,3)); } } $(pageSeat).after(futsbcup.keys.html.countButton.replace("{target}",requirementTarget)) $("#goToFutCd").click(function () { GM_log(window.requirementTarget) var playerArray = getAppMain().getRootViewController().getPresentedViewController().getCurrentViewController().getCurrentController()._squad.getFieldPlayers(); var playerRatingText = ""; var targetText = "target=" + window.requirementTarget.toString(); var playerNumber = []; for (let index = 0; index < playerArray.length; index++) { if(playerArray[index].isBrick() == false){ if(playerArray[index].getItem().rating !== 0){ playerNumber.push(playerArray[index].getItem().rating); } }else{ playerNumber.push(0); } } if(playerNumber.length == 0){ GM_log("*无评分列表*"); }else{ playerRatingText = "&ratings=" + playerNumber.join(","); GM_log(playerRatingText); } GM_openInTab("https://futcd.com/sbc.html?" + targetText + playerRatingText, { active: true, insert: true, setParent :true }); }); } },500) } $(pageSeat).after(this.keys.html.copyButton.replace("{sbcId}",sbcId)) }; futsbcup.searchInput = function(controller,positionOpen){ for(var i=0;i= futsbcup.keys.positionExchange[futsbcup.keys.positionInitial].length){ toggleIndex = 0; } GM_log(toggleIndex) positionController.setIndexById(futsbcup.keys.positionExchange[futsbcup.keys.positionInitial][toggleIndex]) }); futsbcup.positionBind(positionController) } } $(this.keys.selector.searchInput).bind('input propertychange', function() { var targetObject = $(this).parents(".ut-search-filter-control--row").siblings("ul.inline-list"); var targetPanel = targetObject.parent(".inline-container"); var targetPanelTop = targetPanel.position().top; targetObject.css("height","14rem").css("background-color","#171826") targetObject.children("li").show(); if($(this).val().length > 0){ var targetLength = targetObject.children("li:contains('" + $(this).val() + "')").length; if(targetLength > 0){ targetObject.children("li:not(:contains('" + $(this).val() + "'))").hide(); GM_log(targetLength) if(targetLength < 4 && targetPanelTop !== 0){ var targetHeight = (4 - targetLength) * 49; GM_log(targetHeight + "px"); targetObject.css("height","calc(14rem - " + targetHeight + "px)"); targetPanel.css("top","calc(-224px + " + targetHeight + "px)"); }else{ targetObject.css("height","14rem"); if(targetPanelTop !== 0){ targetPanel.css("top","-224px"); } } } }else{ targetObject.css("height","14rem"); if(targetPanelTop !== 0){ targetPanel.css("top","-224px"); } } }); }; 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.SSS){ if($(futsbcup.keys.selector.copyButton).length === 0){ futsbcup.copyButton(controller.className,controller); } }; if(controller.className == futsbcup.keys.title.SSS || controller.className == futsbcup.keys.title.SS){ var rightController = controller._rightController._currentController.getView(); if(rightController.className == futsbcup.keys.title.CS){ var userSortId = GM_getValue("userSort", 2) if(futsbcup.keys.setSrot == false){ rightController.getSortDropDown().setIndexById(userSortId) futsbcup.keys.setSrot = true; } if($(futsbcup.keys.selector.searchInput).length === 0){ futsbcup.searchInput(rightController._filterContainer); } } if(rightController.className == futsbcup.keys.title.CSR){ GM_log("*搜索结果页面*") var rightchildController = controller._rightController._childViewControllers; for (let index = 0; index < rightchildController.length; index++) { if(rightchildController[index].getView().className == futsbcup.keys.title.CS){ var userSort = rightchildController[index].getView().getSortDropDown().getId(); var cookieSrot = GM_getValue("userSort", 2); if(cookieSrot !== userSort && futsbcup.keys.setSrot == true){ GM_setValue("userSort", userSort); GM_log("*发现差值进行存储*"); futsbcup.keys.setSrot = false; } } } } if(rightController.className == futsbcup.keys.title.MF){ if($(futsbcup.keys.selector.searchInput).length === 0){ futsbcup.searchInput(rightController._searchFilters); } } if(rightController.className == futsbcup.keys.title.ID){ GM_log("*发现重新选择位置进行搜索重新填充排序*") futsbcup.keys.setSrot = false; } }; if(controller.getView().className == futsbcup.keys.title.MF){ if(controller.getView()._tabMenu.selectedItemId === 0){ if($(futsbcup.keys.selector.searchInput).length === 0){ futsbcup.searchInput(controller.getView()._searchFilters,1); } } }; }; futsbcup.positionBind = function(controller){ $(controller.__root).bind({ DOMNodeInserted:function(){ if(controller.isOpen){ $(futsbcup.keys.selector.positionButton).hide(); }else{ $(futsbcup.keys.selector.positionButton).show(); } }, DOMNodeRemoved:function(){ if(controller.isOpen){ $(futsbcup.keys.selector.positionButton).hide(); }else{ $(futsbcup.keys.selector.positionButton).show(); } }, }); }; 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() })();