您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
将 YouTube Shorts 网址转换为常规的 YouTube 视频网址。
当前为
- // ==UserScript==
- // @name YouTube Shorts URL Conversion Button
- // @name:zh-TW YouTube Shorts URL 轉換按鈕
- // @name:ja YouTube Shorts URL コンバーター
- // @name:zh-CN YouTube Shorts URL 转换按钮
- // @name:ko YouTube Shorts URL 변환 버튼
- // @name:ru Кнопка преобразования URL YouTube Shorts
- // @name:de YouTube Shorts URL Konvertierungstaste
- // @name:es Botón de conversión de URL de YouTube Shorts
- // @name:fr Bouton de conversion d'URL YouTube Shorts
- // @name:it Pulsante di conversione URL YouTube Shorts
- // @namespace http://tampermonkey.net/
- // @version 1.2
- // @description Convert YouTube Shorts URL to regular YouTube video URL.
- // @description:zh-TW 將 YouTube Shorts 網址轉換為常規的 YouTube 影片網址。
- // @description:ja YouTube Shorts URLを通常のYouTubeビデオURLに変換します。
- // @description:zh-CN 将 YouTube Shorts 网址转换为常规的 YouTube 视频网址。
- // @description:ko YouTube Shorts URL을 일반 YouTube 비디오 URL로 변환합니다.
- // @description:ru Преобразование URL YouTube Shorts в обычный URL видео YouTube.
- // @description:de Konvertiere YouTube Shorts URL in reguläre YouTube Video URL.
- // @description:es Convierte la URL de YouTube Shorts en una URL de video de YouTube normal.
- // @description:fr Convertir l'URL YouTube Shorts en URL vidéo YouTube classique.
- // @description:it Converti l'URL YouTube Shorts in URL video YouTube normale.
- // @author 鮪魚大師
- // @match https://www.youtube.com/*
- // @grant none
- // @license MIT
- // ==/UserScript==
- (function() {
- 'use strict';
- let convertButton;
- const lang = navigator.language;
- const langData = [
- {
- name: "English",
- match: ["en"],
- lang: {
- buttonText: "Convert Shorts URL",
- buttonTitle: "Convert Shorts URL to regular video URL",
- },
- },
- {
- name: "Chinese (Traditional)",
- match: ["zh-TW"],
- lang: {
- buttonText: "Shorts網址轉換",
- buttonTitle: "將Shorts網址轉換成一般影片網址",
- },
- },
- {
- name: "Japanese",
- match: ["ja"],
- lang: {
- buttonText: "YouTube Shorts URL コンバーター",
- buttonTitle: "YouTube Shorts URLを通常のYouTubeビデオURLに変換します",
- },
- },
- {
- name: "Chinese (Simplified)",
- match: ["zh-CN"],
- lang: {
- buttonText: "YouTube Shorts URL 转换按钮",
- buttonTitle: "将 YouTube Shorts 网址转换为常规的 YouTube 视频网址",
- },
- },
- {
- name: "Korean",
- match: ["ko"],
- lang: {
- buttonText: "YouTube Shorts URL 변환",
- buttonTitle: "YouTube Shorts URL을 일반 YouTube 비디오 URL로 변환합니다",
- },
- },
- {
- name: "Russian",
- match: ["ru"],
- lang: {
- buttonText: "Конвертировать URL YouTube Shorts",
- buttonTitle: "Преобразование URL YouTube Shorts в обычный URL видео YouTube",
- },
- },
- {
- name: "German",
- match: ["de"],
- lang: {
- buttonText: "YouTube Shorts URL Konvertierung",
- buttonTitle: "Konvertiere YouTube Shorts URL in reguläre YouTube Video URL",
- },
- },
- {
- name: "Spanish",
- match: ["es"],
- lang: {
- buttonText: "Botón de conversión de URL de YouTube Shorts",
- buttonTitle: "Convierte la URL de YouTube Shorts en una URL de video de YouTube normal",
- },
- },
- {
- name: "French",
- match: ["fr"],
- lang: {
- buttonText: "Bouton de conversion d'URL YouTube Shorts",
- buttonTitle: "Convertir l'URL YouTube Shorts en URL vidéo YouTube classique",
- },
- },
- {
- name: "Italian",
- match: ["it"],
- lang: {
- buttonText: "Pulsante di conversione URL YouTube Shorts",
- buttonTitle: "Converti l'URL YouTube Shorts in URL video YouTube normale",
- },
- },
- ];
- function getLanguageData() {
- for (const data of langData) {
- if (data.match.includes(lang)) {
- return data.lang;
- }
- }
- return langData[0].lang; // Default to English if no match is found
- }
- const languageData = getLanguageData();
- function createConvertButton() {
- if (!convertButton) {
- convertButton = document.createElement('button');
- convertButton.textContent = languageData.buttonText;
- convertButton.style.position = 'fixed';
- convertButton.style.top = '150px';
- convertButton.style.right = '10px';
- convertButton.style.zIndex = '9999';
- convertButton.style.backgroundColor = '#FF0000';
- convertButton.style.color = '#FFFFFF';
- convertButton.style.fontSize = '24px';
- convertButton.style.padding = '10px 20px';
- convertButton.style.border = 'none';
- convertButton.style.borderRadius = '5px';
- convertButton.title = languageData.buttonTitle;
- document.body.appendChild(convertButton);
- convertButton.addEventListener('click', convertURL);
- }
- }
- function convertURL() {
- const currentURL = window.location.href;
- if (currentURL.includes("youtube.com/shorts/")) {
- const match = currentURL.match(/https:\/\/www\.youtube\.com\/shorts\/([A-Za-z0-9_-]+)/);
- if (match) {
- const videoID = match[1];
- const videoURL = `https://www.youtube.com/watch?v=${videoID}`;
- window.location.href = videoURL;
- }
- }
- }
- function removeConvertButton() {
- if (convertButton) {
- convertButton.remove();
- convertButton = null;
- }
- }
- function checkAndCreateButton() {
- if (window.location.href.includes("youtube.com/shorts/")) {
- createConvertButton();
- } else {
- removeConvertButton();
- }
- }
- checkAndCreateButton();
- window.addEventListener('popstate', checkAndCreateButton);
- const observer = new MutationObserver(function(mutationsList, observer) {
- for (const mutation of mutationsList) {
- if (mutation.type === 'childList') {
- checkAndCreateButton();
- }
- }
- });
- observer.observe(document.documentElement, { childList: true, subtree: true });
- })();