1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- // ==UserScript==
- // @name T-B站-复制视频引用
- // @namespace Violentmonkey Scripts
- // @match https://www.bilibili.com/video/*
- // @grant none
- // @version 1.0
- // @author tianyunperfect
- // @require https://cdn.bootcdn.net/ajax/libs/jquery/3.3.1/jquery.min.js
- // @description 2021/1/30 下午7:09:51
- // ==/UserScript==
- (function () {
- 'use strict';
- jQuery.noConflict();
- function getTempId() {
- return "myTmp" + Math.floor(Math.random() * 10000);
- }
- function myCopy(string) {
- let tmpId = getTempId();
- jQuery('body').append(jQuery("<div id='" + tmpId + "'>" + string + "</div>"))
- let range = document.createRange();
- range.selectNode(jQuery("#" + tmpId)[0]);
- // 清除选择
- window.getSelection().removeAllRanges();
- window.getSelection().addRange(range);
- console.log('复制成功');
- document.execCommand('copy');
- // 清除选择
- window.getSelection().removeAllRanges();
- jQuery('#' + tmpId).remove();
- }
- jQuery('.tit').dblclick(function () {
- let bvid = window.__INITIAL_STATE__.videoData.bvid;
- let aid = window.__INITIAL_STATE__.videoData.aid;
- let cid = window.__INITIAL_STATE__.videoData.cid;
- // let url = `https://player.bilibili.com/player.html?high_quality=1&danmaku=0&bvid=${bvid}`;
- let url = `https://video-direct-link.vercel.app/bili.mp4?aid=${aid}&bvid=${bvid}&cid=${cid}`;
- myCopy(url);
- let tmpId = getTempId();
- jQuery(".tit").eq(0).append(jQuery('<span class="tag" id="' + tmpId + '">:已复制</span>'));
- setTimeout(() => {
- jQuery('#' + tmpId).remove();
- }, 1500)
- });
- })();
|