🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

Tumblr get video source

Gets the video source url for the first video on a tumblr post.

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

You will need to install an extension such as Tampermonkey to install this script.

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         Tumblr get video source
// @namespace    http://tampermonkey.net/
// @version      0.6
// @description  Gets the video source url for the first video on a tumblr post.
// @author       You
// @match        https://*.tumblr.com/post/*
// @match        https://www.tumblr.com/video/*
// @grant        GM_setClipboard
// @grant        GM_registerMenuCommand
// @run-at       document-idle
// ==/UserScript==

if(window.top !== window.self) {
  const videoSourceElem = document.querySelector('video source');
  if(!videoSourceElem){
    return;
  }
  window.top.postMessage({
    iframeVideoUrl: window.location.href,
    iframeVideoSrc: videoSourceElem.src
  }, "*")
  return
}


const parentPostID = window.location.href.split('/')[4]
let iframeVideoSrc = ''

window.addEventListener('message', function(event) {
  if(!event.data.iframeVideoUrl || !event.data.iframeVideoSrc) {
    return
  }
  const iframeVideoID = event.data.iframeVideoUrl.split('/')[5]

 if(parentPostID === iframeVideoID){
    iframeVideoSrc = event.data.iframeVideoSrc
    if(iframeVideoSrc.endsWith('/480')){
      iframeVideoSrc = iframeVideoSrc.slice(0, -3)
    }
    console.log(iframeVideoSrc)
  }
}, false)

function getVideoUrl(){
  // GM_setClipboard(iframeVideoSrc)
  
  var textarea = document.createElement('textarea')

  textarea.setAttribute('id', 'linksTextarea')
  textarea.setAttribute('style', `
    position: absolute;
    top: 60px;
    left:40px;
    width:1000px;
    height:500px;
    background-color:white;
    z-index:100000;
    padding:10px;
  `)
  textarea.value = iframeVideoSrc
  document.body.appendChild(textarea)
  window.scrollTo(0,0)
}

GM_registerMenuCommand('Get Video Url', getVideoUrl)