您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Embed YouTube videos on elamigos.site/data/* pages if a YouTube link is present.
// ==UserScript== // @name Elamigos - Embed YouTube Video // @namespace http://tampermonkey.net/ // @version 0.2 // @description Embed YouTube videos on elamigos.site/data/* pages if a YouTube link is present. // @author Drigtime // @match https://elamigos.site/data/* // @icon https://www.google.com/s2/favicons?sz=64&domain=elamigos.site // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; // Function to extract the YouTube video ID from a YouTube link function extractVideoId(url) { const match = url.match(/(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?feature=player_embedded&v=))([^&\n?#]+)/); return match && match[1]; } // Find all links on the page const allParagraphs = document.querySelectorAll('p'); // Loop through each link allParagraphs.forEach(paragraph => { const text = paragraph.textContent; const videoId = extractVideoId(text); if (videoId) { // Create an iframe to embed the YouTube video const iframe = document.createElement('iframe'); iframe.width = '560'; iframe.height = '315'; iframe.src = `https://www.youtube.com/embed/${videoId}`; iframe.frameborder = '0'; iframe.allow = 'fullscreen'; // Replace the link with the embedded video paragraph.parentNode.replaceChild(iframe, paragraph); } }); })();