Last active
January 22, 2025 02:27
-
-
Save journey-ad/5d3021fd40db75de2df827b876ef5b7e to your computer and use it in GitHub Desktop.
哔站直播间的2233娘挂件替换为全裸版本
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name 哔站直播全裸2233娘 | |
// @description 哔站直播间的2233娘挂件替换为全裸版本 | |
// @description:zh-TW 嗶站直播間的2233娘掛件替換為全裸版本 | |
// @namespace https://github.com/journey-ad | |
// @author journey-ad | |
// @include *://live.bilibili.com/* | |
// @require https://cdn.jsdelivr.net/jquery/1.12.4/jquery.min.js | |
// @require https://cdn.jsdelivr.net/gh/journey-ad/blog-img/libs/2233.zenra/live2d.js?v=1.1.9 | |
// @version 1.1.9 | |
// @license GPL v2 | |
// @run-at document-end | |
// @grant none | |
// ==/UserScript== | |
(function(){ | |
'use strict'; | |
//监听DOM树变化 | |
var observeDOMChanges = (function(){ | |
var flag = true; | |
var ts = Date.now(); | |
// 对变化的 dom 的操作 | |
var changedHandler = function (element) { | |
if(flag && document.querySelectorAll('canvas.haruna-canvas').length > 0){ | |
console.log('发现2233,开始替换'); | |
//插旗 | |
flag = false; | |
//移除原有的画布 | |
var canvas = document.querySelectorAll('canvas.haruna-canvas')[0]; | |
var parent = canvas.parentElement; | |
parent.removeChild(canvas); | |
//然后新建一个 | |
var newcanvas = document.createElement('canvas'); | |
newcanvas.id = 'live2d'; | |
newcanvas.className = 'haruna-canvas'; | |
newcanvas.width = 440; | |
newcanvas.height = 500; | |
//宽高样式设为画布的一半 优化高分屏显示效果 | |
newcanvas.style.width = '220px'; | |
newcanvas.style.height = '250px'; | |
parent.insertBefore(newcanvas, parent.firstChild); | |
//看看是22还是33 | |
var type = '22'; | |
$.ajax({ | |
type: "GET", | |
url: String.format('https://api.live.bilibili.com/live/getRoomKanBanModel?roomid={0}', BilibiliLive.ROOMID), | |
async: false, | |
success : function(data) { | |
type = data.label || type; | |
} | |
}); | |
var jsonUrl = String.format('https://cdn.jsdelivr.net/gh/journey-ad/blog-img/libs/2233.zenra/{0}/{0}.zenra{1}.json?v1', type, (window.devicePixelRatio > 1 ? '@2x' : '')); | |
//加载没穿衣服的2233 | |
loadlive2d("live2d", jsonUrl); | |
//使其支持拖动 | |
var _move = false; | |
var ismove = false; | |
var _x, _y; | |
$(".live-haruna-ctnr").mousedown(function(e){ | |
_move = true; | |
_x = e.pageX-parseInt($(".live-haruna-ctnr").css("left")); | |
_y = e.pageY-parseInt($(".live-haruna-ctnr").css("top")); | |
}); | |
$(document).mousemove(function(e){ | |
if(_move){ | |
var x = e.pageX-_x; | |
var y = e.pageY-_y; | |
var wx = $(window).width()-$('.live-haruna-ctnr').width(); | |
var dy = $(document).height()-$('.live-haruna-ctnr').height(); | |
if(x>=0&&x<=wx&&y>0&&y<=dy){ | |
$(".live-haruna-ctnr").css({ | |
top:y, | |
left:x | |
}); | |
ismove = true; | |
} | |
} | |
}).mouseup(function(){ | |
_move = false; | |
}); | |
//点击说话 | |
$("#live2d").click(function(){ | |
var msgs = ["你要干嘛呀?","鼠…鼠标放错地方了!","喵喵喵?","萝莉控是什么呀?","怕怕","你看到我的小熊了吗"]; | |
var i = Math.floor(Math.random() * msgs.length); | |
showMessage(msgs[i]); | |
}); | |
//移除事件监听 | |
observer.disconnect(); | |
document.removeEventListener("DOMSubtreeModified", changedHandler, false); | |
console.log('没穿衣服的2233替换完成'); | |
} | |
if(Date.now() - ts >= 30 * 1000){ | |
flag = false; | |
observer.disconnect(); | |
document.removeEventListener("DOMSubtreeModified", changedHandler, false); | |
console.log('超时'); | |
} | |
}; | |
// 检查 MutationObserver 浏览器兼容 | |
var MutationObserver = window.MutationObserver || | |
window.WebKitMutationObserver || | |
window.MozMutationObserver; | |
if (MutationObserver) { | |
// MutationObserver 配置 | |
var MutationObserverConfig = { | |
// 监听子节点 | |
childList: true, | |
// 监听 href 属性 | |
attributes: true, | |
// 监听整棵树 | |
subtree: true | |
}; | |
// 监听器 | |
var observer = new MutationObserver(function (mutations) { | |
mutations.forEach(function (mutation) { | |
// 处理 变化的 DOM | |
changedHandler(mutation.target); | |
// 处理 新增的 DOM | |
if (mutation.addedNodes) { | |
mutation.addedNodes.forEach(changedHandler); | |
} | |
// 删除的 DOM 无需处理 (mutation.removedNodes) | |
}); | |
}); | |
return function () { | |
// 开始监听 | |
observer.observe(document.body, MutationObserverConfig); | |
}; | |
} else if (document.body.addEventListener) { | |
// addEventListener 和 Mutation events 都是 IE 9 以上才支持 | |
var bindMutationEvents = function (eventName) { | |
document.body.addEventListener(eventName, function (e) { | |
changedHandler(e.target); | |
}); | |
}; | |
var binded = false; | |
return function () { | |
if (binded) { | |
return; | |
} | |
binded = true; | |
bindMutationEvents('DOMSubtreeModified'); | |
bindMutationEvents('DOMNodeInserted'); | |
}; | |
} else { | |
// IE 8- 就不管了 | |
return function () { | |
console.log('MutationObserver not support!'); | |
}; | |
} | |
})(); | |
observeDOMChanges(); | |
//封装一些方法 | |
String.format = function(src){ | |
if (arguments.length == 0) return null; | |
var args = Array.prototype.slice.call(arguments, 1); | |
return src.replace(/\{(\d+)\}/g, function(m, i){ | |
return args[i]; | |
}); | |
}; | |
function showMessage(a,b){ | |
if(b === null) b = 10000; | |
$(".base-bubble,.speaking-bubble,.bubble-item").hide().stop(); | |
$(".speaking-bubble").html(a); | |
$(".base-bubble,.speaking-bubble,.bubble-item").fadeTo("10",1); | |
$(".base-bubble,.speaking-bubble,.bubble-item").fadeOut(b); | |
} | |
})(); |
大佬强无敌
直呼会玩
直呼会玩
6
怎么用到油猴里呢
只有pc端的网页有挂件吗,手机版是不是没有
嗯,好像是的,至少我没看到过
…------------------ 原始邮件 ------------------
发件人: "287976255"<[email protected]>;
发送时间: 2020年11月19日(星期四) 中午11:10
收件人: "journey-ad"<[email protected]>;
抄送: "ゞ 正在缓冲99%"<[email protected]>; "Comment"<[email protected]>;
主题: Re: journey-ad/2233.zenra.js
@287976255 commented on this gist.
只有pc端的网页有挂件吗,手机版是不是没有
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
打开油猴编辑代码的地方,再把代码复制进去。。
…------------------ 原始邮件 ------------------
发件人: "qhl123456"<[email protected]>;
发送时间: 2020年11月19日(星期四) 上午8:52
收件人: "journey-ad"<[email protected]>;
抄送: "ゞ 正在缓冲99%"<[email protected]>; "Comment"<[email protected]>;
主题: Re: journey-ad/2233.zenra.js
@qhl123456 commented on this gist.
怎么用到油猴里呢
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
牛啊
图片把我看喷了
2233娘挂件是什么东西……我咋没见过呢
失效了呀
失效了呀
已修复
看到2233娘了,第一次回知道有这么个玩意儿
好耶,可以对着冲么[doge]
嘉门
6b
好像失效了,很久没看电脑端直播打开发现失效了
竟然一眨眼五六年过去了,好久没看直播,都忘了这个了,现在好像直播间已经没有2233娘的挂件了吧
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
好大的胆子 敢开233娘的车