// ==UserScript== // @name Tieba_Insert_MusicLink // @namespace tieba // @description 贴吧自定义插入mp3链接 // @include http://tieba.baidu.com/* // @version 3 // @author 初代作者为校长之怒/修复(绯色) // @downloadURL none // ==/UserScript== /*** 2014年之前版本信息丢失,且本脚本真正的作者早已无更新 2014/6/1 修复火狐吧友说该脚本在chrome的浮动回帖框会出现两个插入框的问题(在此吐槽,狐吧基佬跑去使用chrome闹哪样) */ //JQuery支持 $ = unsafeWindow.$; //音乐链接面板 GUI界面 var musicUrl = '歌名'; musicUrl += ' 链接'; musicUrl += ' 插入音乐链接'; //css var css = '.label{display:inline-block;padding:2px 4px;font-size:11.844px;font-weight:bold;line-height:14px;color:#ffffff;vertical-align:baseline;white-space:nowrap;text-shadow:0 -1px 0 rgba(0, 0, 0, 0.25);background-color:#999999;}\ .btn{font-size: 12px;height: 25.6px;line-height: 25.6px;padding: 0px 2px;transition-property: #000, color;\ transition-duration: 0.3s;\ box-shadow: none;\ background: none repeat scroll 0% 0% #00A1CB;\ color: #FFF;\ text-shadow: none;\ border: medium none;}'; GM_addStyle(css); //调用控制 addNodeInsertedListener('#tb_rich_poster_container', function() { $("#tb_rich_poster").append(musicUrl); $('#convertLinks').click(check); }); //函数 检查表单 function check() { if (($('#musicUrlTitle').val() == '') || ($('#musicUrl').val() == '')) { $('#Check_status').css('display', 'block'); setTimeout(function() { $('#Check_status').hide(); }, 2000); } else { rewriteGetContent(); convertLinks(); } } //插入函数 插入音乐 function convertLinks() { var url = $('#musicUrl').val(); $('#musicUrl').val(''); var title = $('#musicUrlTitle').val(); if (url.indexOf('http://') == -1 && url.indexOf('https://') == -1 && url.indexOf('ftp://') == -1) url = 'http://' + url; var temp = ')+)|(()+$)/g, ""); var embeds = d.match(/]*>/g); if (embeds) { var f = ''; $('#ueditor_replace .BDE_Music').each(function() { var g = $.tb.format(f, { url: $(this).attr('title') }); cr_flash.push(g); }); for (var i = 0; i < embeds.length; i++) d = d.replace(embeds[i], cr_flash[i]); } return d; };