Dropbox Direct Links

Displays direct link to shared file for embedding purposes

Stan na 04-12-2014. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Dropbox Direct Links
// @namespace    https://github.com/phracker
// @version      1.1.18
// @description  Displays direct link to shared file for embedding purposes
//
// @grant        GM_setClipboard
// @grant        GM_getResourceText
// @grant        GM_getResourceURL
// @grant        GM_log
// @grant        GM_getValue
// @grant        GM_setValue
// @grant        GM_xmlhttpRequest
// @grant        GM_openInTab
// @grant        GM_info
//
// @require      https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.js
// @require      https://cdnjs.cloudflare.com/ajax/libs/zeroclipboard/2.1.6/ZeroClipboard.js
// @resource     zcswf https://cdnjs.cloudflare.com/ajax/libs/zeroclipboard/2.1.6/ZeroClipboard.swf
// @resource     zc_swf https://dl.dropboxusercontent.com/s/z8gln344lvluj17/ZeroClipboard.swf
//
// @include      http*://*dropbox.com/s/*/*
// ==/UserScript==

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

// Create direct link and copy button
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 Direct 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);
// Append to page
document.getElementById('page-content').appendChild(div);

//Create menu button
var mb = document.createElement('button');
mb.setAttribute('id', 'mdurl');
mb.setAttribute('data-clipboard-text', durl);
mb.setAttribute('title', 'Copy Direct URL');
mb.setAttribute('style', 'display: inline-block; vertical-align: middle; zoom: 1; margin-left: 8px;');
mb.setAttribute('class', 'freshbutton-blue');
mb.appendChild(document.createTextNode('Copy Direct URL'));
// Add to menu
var buttons = document.getElementsByClassName('buttons').item(0);
var extrasButton = document.getElementById('non-owner-menu-button');
buttons.insertBefore(mb,extrasButton);


ZeroClipboard.config({
  swfPath: GM_getResourceURL("zcswf")
  // swfPath: "https://dl.dropboxusercontent.com/s/z8gln344lvluj17/ZeroClipboard.swf"
});

var zc = new ZeroClipboard($('#durl'));
zc.on('ready', function(event) {
  console.log('durl ready'] );
  zc.on('copy', function(event) {
    event.clipboardData.setData('text/plain', durl);
  });
  zc.on('aftercopy', function(event) {
    console.log('Copied: ' + event.data['text/plain'] );
  });
});
var zcm = new ZeroClipboard($('#mdurl'));
zcm.on('ready', function(event) {
  console.log('mdurl ready'] );
  zcm.on('copy', function(event) {
    event.clipboardData.setData('text/plain', durl);
  });
  zc.on('aftercopy', function(event) {
    console.log('Copied: ' + event.data['text/plain'] );
  });
});