// ==UserScript== // @name b站直播徽章切换增强 // @namespace http://tampermonkey.net/ // @version 0.1 // @description 所有徽章都能看到了 // @author You // @include /https:\/\/live\.bilibili\.com\/(blanc\/)?\d+/ // @icon http://bilibili.com/favicon.ico // @grant GM_addStyle // @downloadURL none // ==/UserScript== (function () { 'use strict'; GM_addStyle(` .medal-item>.progress-level-div, .medal-item>.limit-progress-div { display: none } .medal-wear-body .medal-item { cursor: pointer; padding: 6px 12px 7px; margin: 1px; background: 0; border: 1px solid #eee; border-radius:5px; width:calc(100% - 5px); text-align:left } .medal-wear-body .medal-item:hover { background-color: #eef5fb; } .medal-wear-body .medal-item .living-gif { background-image: url(//s1.hdslb.com/bfs/static/blive/blfe-live-room/static/img/living.44021fe..gif); background-size: cover; width: 12px; height: 12px; } .medal-wear-body{ padding-top:4px !important; max-height:240px; overflow:auto; } .medal-wear-body .medal-item>span{ margin-left: 10px; color: #666; max-width: 68px; position: relative; `); function ajaxEventTrigger(event) { var ajaxEvent = new CustomEvent(event, { detail: this }); unsafeWindow.dispatchEvent(ajaxEvent); } var oldXHR = unsafeWindow.XMLHttpRequest; function newXHR() { var realXHR = new oldXHR(); realXHR.addEventListener('abort', function () { ajaxEventTrigger.call(this, 'ajaxAbort'); }, false); realXHR.addEventListener('error', function () { ajaxEventTrigger.call(this, 'ajaxError'); }, false); realXHR.addEventListener('load', function () { ajaxEventTrigger.call(this, 'ajaxLoad'); }, false); realXHR.addEventListener('loadstart', function () { ajaxEventTrigger.call(this, 'ajaxLoadStart'); }, false); realXHR.addEventListener('progress', function () { ajaxEventTrigger.call(this, 'ajaxProgress'); }, false); realXHR.addEventListener('timeout', function () { ajaxEventTrigger.call(this, 'ajaxTimeout'); }, false); realXHR.addEventListener('loadend', function () { ajaxEventTrigger.call(this, 'ajaxLoadEnd'); }, false); realXHR.addEventListener('readystatechange', function () { ajaxEventTrigger.call(this, 'ajaxReadyStateChange'); }, false); return realXHR; } unsafeWindow.XMLHttpRequest = newXHR; var jct = document.cookie.match(/bili_jct=(\w*); /) && document.cookie.match(/bili_jct=(\w*); /)[1]; unsafeWindow.addEventListener('ajaxLoadEnd', function (e) { if (e.detail.responseURL.indexOf("fans_medal/v1/FansMedal/get_list_in_room") > 0) { let list = JSON.parse(e.detail.responseText).data; let body = document.querySelector(".medal-wear-body"); body.innerHTML = ""; for (let item of list) { let ele = document.createElement("button"); ele.className = "medal-item"; ele.setAttribute("data-medal_id", item.medal_id); ele.innerHTML = `