您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Embeds images which Discourse fails to embed
// ==UserScript== // @name WaniKani Forums: Giphy/Pinterest embedder // @namespace http://tampermonkey.net/ // @version 0.1.9 // @description Embeds images which Discourse fails to embed // @author Kumirei // @include https://community.wanikani.com* // @require https://greatest.deepsurf.us/scripts/432418-wait-for-selector/code/Wait%20For%20Selector.js?version=974318 // @grant none // ==/UserScript== (function($, wfs) { wfs.wait('.topic-body p > a[target="_blank"]', embedImages) //embeds images if there are any broken ones to find function embedImages(e) { var embed = false; var url = $(e).attr('href'); if (e.innerText == "") { if (url.match(/https:\/\/media\.giphy\.com\/media\/.+\/giphy\.gif/) != null) { var ID = url.split("/")[4]; url = "https://i.giphy.com/media/"+ID+"/giphy.webp"; embed = true; } else if (url.match(/https:\/\/i\.pinimg\.com\/.*\.gif/) != null) embed = true; if (embed) { var img = document.createElement('img'); img.src = url; img.alt = 'Loading image...'; var elem = $(e.parentElement); elem.addClass("lightbox"); elem.empty(); elem.append(img); elem.append('<div class="meta">'+ ' <span class="filename"><small>Embedded by the <i>Giphy/Pinterest Embedder</i>'+ ' </small></span></div>'); } } } })(window.jQuery, window.wfs);