Skip to content

Instantly share code, notes, and snippets.

@MondoGao
Last active March 18, 2016 13:16
Show Gist options
  • Save MondoGao/ce7e98f7b764d372b80a to your computer and use it in GitHub Desktop.
Save MondoGao/ce7e98f7b764d372b80a to your computer and use it in GitHub Desktop.
hudbt - 表情替换-阿鲁
//hudbt-smile-aru.js
$(function() {
replaceSmile();
$("#showmoresmilies").click(function() {
setTimeout(replaceSmile, 500);
});
addChangeButton();
});
function replaceSmile() {
$("img[src*=smilies]").each(function() {
var src = $(this).attr('src');
var num = src.slice(src.lastIndexOf("\/") + 1, src.length - 4);
if ($(this).parent().hasClass('smileit')) {
if (Number(num) < 125) {
$(this).attr('src', 'http\:\/\/bbs\.maxthon\.cn\/static\/image\/smiley\/ARU\/ARU\_' + num + "\.png");
$(this).parent('a').attr('smile', Number($(this).parent('a').attr('smile')) + 1000);
}
} else if ($(this).parent().hasClass('bbcode')) {
if (Number(num) > 1000) {
$(this).attr('src', 'http\:\/\/bbs\.maxthon\.cn\/static\/image\/smiley\/ARU\/ARU\_' + Number(num - 1000) + "\.png");
}
}
});
}
function addChangeButton() {
$changeSmileButton = $("<input />").attr({
'id': 'changeSmileButton',
'type': 'button',
'value': '切换表情'
}).click(changeSmileButtons);
setTimeout(function() {
if ($("input#qr").parent().attr('id') == 'commit-btn') {
$changeSmileButton.addClass('ui-button ui-widget ui-state-default');
} else {
$changeSmileButton.addClass('btn');
}
$("input#qr").after($changeSmileButton);
}, 500);
}
var flagS = 1;
function changeSmileButtons() {
if (flagS == 1) {
$("img[src*=ARU]").each(function() {
if ($(this).parent().hasClass('smileit')) {
var num = $(this).parent().attr('smile');
if (Number(num) > 1000) {
$(this).attr('src', '\/\/hudbt.hust.edu.cn/pic/smilies/' + Number(num - 1000) + "\.gif");
$(this).parent('a').attr('smile', Number($(this).parent('a').attr('smile')) - 1000);
}
flagS = 0;
}
});
} else if (flagS == 0) {
$("img[src*=smilies]").each(function() {
if ($(this).parent().hasClass('smileit')) {
var num = $(this).parent().attr('smile');
if (Number(num) < 125) {
$(this).attr('src', 'http\:\/\/bbs\.maxthon\.cn\/static\/image\/smiley\/ARU\/ARU\_' + num + "\.png");
$(this).parent('a').attr('smile', Number($(this).parent('a').attr('smile')) + 1000);
}
flagS = 1;
}
});
}
}
//hudbt-smile-aru.js end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment