Greasy Fork

Greasy Fork is available in English.

Dropbox Direct Links

Displays direct link to shared file for embedding purposes

当前为 2014-09-10 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Dropbox Direct Links
// @namespace    https://github.com/phracker
// @version      1.0
// @description  Displays direct link to shared file for embedding purposes
//
// @require      https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.js
// @require      https://cdnjs.cloudflare.com/ajax/libs/zeroclipboard/2.1.5/ZeroClipboard.js
// @include      http*://*dropbox.com/s/*/*
// ==/UserScript==

// direct url
var durl = document.URL.replace('www.dropbox.com', 'dl.dropboxusercontent.com').replace(/\?.*/, '').replace(/\#.*/, '');

var div = document.createElement('div');
div.setAttribute('align', 'center');

div.setAttribute('style', 'font-size: 12px; vertical-align: middle;');
var a = document.createElement('a');
a.href = durl;
a.setAttribute('style', 'text-decoration: none;');
a.textContent = durl;

var b = document.createElement('button');
b.setAttribute('id', 'durl');
b.setAttribute('data-clipboard-text', durl);
b.setAttribute('title', 'Copy URL');
b.setAttribute('style', 'font-size: 10px; padding: 0px 6px; margin-left: 1em; font-weight: 800;');
b.setAttribute('class', 'freshbutton-lightblue');
b.appendChild(document.createTextNode('Copy'));
div.appendChild(document.createTextNode('Direct: '));
div.appendChild(a);
div.appendChild(b);
document.getElementById('page-content').appendChild(div);

ZeroClipboard.config({
  swfPath: "https://cdnjs.cloudflare.com/ajax/libs/zeroclipboard/2.1.5/ZeroClipboard.swf"
});
var zc = new ZeroClipboard($('#durl'));
zc.on('ready', function(event) {
  zc.on('copy', function(event) {
    event.clipboardData.setData('text/plain', durl);
  });
});