// ==UserScript== // @name keylol有卡游戏标记 // @namespace http://tampermonkey.net/ // @icon https://keylol.com/favicon.ico // @version 0.17 // @description keylol论坛有卡游戏标记 嗨皮喜加一 // @author wsz987 // @match https://keylol.com/* // @match https://www.keylol.com/* // @require https://cdn.staticfile.org/jquery/1.12.4/jquery.min.js // @supportURL https://keylol.com/t587145-1-1 // @downloadURL none // ==/UserScript== (async function() { 'use strict'; var json=await start(); search_card(json).then(add_Btn()); jQuery('body').on("click", "#threadindex > div > ul > li",()=>{ $('.t_f').ready(()=>setTimeout(()=>{search_card(json).then(unauto(),add_Btn())},1000)) }); /*new MutationObserver(()=>{ }).observe(document.querySelector("#postlist>div"),{ attributes: true, childList: true })*/ })(); function search_card(json){ var font_Color_Card = "deeppink", //有卡字体颜色 font_Color_BS="darkorange", //包类型字体颜色 font_Weight = "bolder"; //字体加粗 //颜色自定义可以参考这位老哥 https://keylol.com/t587368-1-1 return new Promise(resolve => { $('.steam-info-link').each(function(){ var arr_href=$(this).context.pathname.split('/') if(arr_href[1]=='bundle'||arr_href[1]=='sub'){ $(this).context.text="["+arr_href[1].charAt(0).toUpperCase() + arr_href[1].slice(1)+"]: "+$(this).context.innerText; $(this).context.style.color=font_Color_BS; console.log($(this).text()); } if(json.hasOwnProperty(arr_href[2])==true){ $(this).context.className+=' own_trading_cards'; $(this).context.text="[Card]: "+$(this).context.innerText; /*按需求添加/删除"//"是否显示有卡标签*/ $(this).context.style.color=font_Color_Card; $(this).context.style.fontWeight = font_Weight; } }) }); } function start(){ return new Promise(resolve => { var settings = { "url": "https://bartervg.com/browse/cards/json/", "method": "GET", "timeout": 0, }; $.ajax(settings).done(function (response) { resolve(response); }); }); }; function unauto(){ $('.plc div.authi>a[rel=nofollow]').eq(0).after(`|标记有卡`); $('#unauto_tab').click(()=>search_card(json)) } function add_Btn(){ if($('.own_trading_cards').length>0){ tab_Btn_a(); //pinkgun(); /*彩蛋*/ } } function tab_Btn_a(){ $('.plc div.authi>a[rel=nofollow]').eq(0).after(`|打包有卡`); $('#tab_Btn_a').click(()=>add_game()) } function pinkgun(){ $("body").append("