BumScript

Show images/video directly in chat!

目前为 2018-12-14 提交的版本。查看 最新版本

// ==UserScript==
// @name         BumScript
// @namespace    http://tampermonkey.net/
// @version      1.4
// @description  Show images/video directly in chat!
// @author       Bum
// @require       http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// @match        https://www.twitch.tv/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    var targetNode = document.getElementById("root");

    // Options for the observer (which mutations to observe)
    var config = { attributes: true, childList: true, subtree: true };

    // Callback function to execute when mutations are observed
    var callback = function(mutationsList, observer) {
        for(var mutation of mutationsList) {
            $(".link-fragment").each(function(){
                    if (($(this).text().indexOf(".jpg") > 0 ) || (($(this).text().indexOf(".png") > 0 )) || (($(this).text().indexOf(".gif") > 0 ))|| (($(this).text().indexOf(".jpeg") > 0 ))|| (($(this).text().indexOf(".webp") > 0 ))){
                        $(this).html("<br><img src='" + $(this).text() + "' width='200px'/>");
                    }
                if ($(this).text().indexOf(".mp4") > 0 ){
                     $(this).html('<br><video width="320" height="240" controls autoplay><source src="'+ $(this).text() +'" type="video/mp4"></video>');
                }
                if ($(this).text().indexOf("www.youtube") > 0 ){
                   $(this).html('<br><iframe width="320" height="240" src="' + $(this).text().replace("watch?v=", "embed/") +'"></iframe>');
                }
                });
            $(".text-fragment").each(function(){
                    if (($(this).text().indexOf(".jpg") > 0 ) || (($(this).text().indexOf(".png") > 0 )) || (($(this).text().indexOf(".gif") > 0 ))|| (($(this).text().indexOf(".jpeg") > 0 ))){
                        $(this).html("<br><img src='" + $(this).text() + "' width='200px'/>");
                    }
                });
        }
    };
    var observer = new MutationObserver(callback);

    // Start observing the target node for configured mutations
    observer.observe(targetNode, config);
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址