Skip to content

Instantly share code, notes, and snippets.

@g8up
Last active October 13, 2016 18:36
Show Gist options
  • Save g8up/2992816d346f56734f6c18aa89e1211b to your computer and use it in GitHub Desktop.
Save g8up/2992816d346f56734f6c18aa89e1211b to your computer and use it in GitHub Desktop.
将页面(http://douyu.shiniv.com/ )中新增的火箭信息导入斗鱼叉叉(> V2.1.1)
javascript:void( (function(){
/**
* 将页面(http://douyu.shiniv.com/)中新增的火箭信息导入斗鱼叉叉(> V2.1.0)
* @usage 需要[制作成 Chrome 书签](http://pan.baidu.com/s/1skgEosX)
* @version 1.0.2
* @create 2016-09-29 00:37:42
*/
var msg = document.querySelector('#message');
msg.removeEventListener('DOMNodeInserted', window.__xx__fishfork__hookRocket);
function getRoomId( el ){
var a = el.querySelector('a');
var href = a.href;
var ret = href.match(/com\/(\d*)\?/);
if( ret.length ){
return ret[1];
}
}
function postMsg( roomId ){
chrome.runtime.sendMessage('kieadkdifhfdpooogdnanljolkekceij', {
action: 'rocket',
from: 'shiniv',
msg: '我襙,二踢脚!',
gift:{
type: 'rocket',
roomId: roomId
}
}, function(){
console.log('fishfork', roomId, new Date() );
});
}
__xx__fishfork__hookRocket = function(ev){
var el = ev.target;
if( el.tagName && el.tagName.toLowerCase() === 'blockquote' && el.className !== 'nonerocket' ){
var roomId = getRoomId( el );
if( roomId ){
postMsg(roomId);
}
}
};
msg.addEventListener("DOMNodeInserted", __xx__fishfork__hookRocket , false);
})() );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment