// ==UserScript== // @name sakugabooru to gif // @namespace https://github.com/VonXXGhost // @version 0.1 // @description 在sakugabooru页面添加打开相关稿件微博gif的选项 // @author VonXXGhost // @match https://sakuga.yshi.org/* // @match https://www.sakugabooru.com/* // @downloadURL none // ==/UserScript== function addWiboImgButton(code) { var options = jQuery('#post-view > div.sidebar > div:nth-child(5) > ul'); options.append(code); } function getImgUrlSuccess(result) { try { var img_url = result['weibo']['img_url']; console.log(img_url); var code = '
  • 打开微博gif/图片
  • '; addWiboImgButton(code); } catch(e) { console.log(e); getImgUrlError(null); } } function getImgUrlError(result) { if (result) { console.log(result.responseText); } var code = '
  • 暂无微博数据
  • '; addWiboImgButton(code); } (function getImgUrl() { var re = /(?<=post\/show\/)(\d+)/; var id = re.exec(window.location.href)[0]; jQuery.ajax({ url: 'https://sakugabot.pw/api/posts/' + id, type: 'GET', dataType: 'json', success: getImgUrlSuccess, error: getImgUrlError }); })();