Created
January 27, 2014 11:37
-
-
Save kamikat/8647086 to your computer and use it in GitHub Desktop.
Bookmarklet generating external link address for SkyDrive
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
var $ = jQuery; | |
// Selected Items | |
var $selected = $('.surface .child .isSelected'); | |
if (!$selected.is('a.file')) { | |
// Handle List Box View | |
$selected = $selected.find('a.file'); | |
} | |
var nyan = $selected.map(function (k, el) { | |
var $el = $(el), $parent = $el.parents('.child'); | |
var filename = $el.attr('aria-label'); | |
var urikey = $parent.attr('item-key'); | |
var match = RegExp.prototype.exec.call( | |
/^id=([0-9a-z!]*)[&$]/gi, // Search for a resid match | |
decodeURIComponent(urikey) | |
), resid = match && match[1]; | |
return { | |
filename: filename, | |
resid: resid | |
}; | |
}); | |
$('.external_links').remove(); | |
$('<div class="external_links" style="position: absolute; left: 120px; top: 60px; width: 457px; height: 310px; background: #FFFFFF; border: 1px solid black; text-align: right;"><textarea style="overflow: auto; width: 417px !important; height: 240px; outline: 0; margin: 10px 10px 10px 10px; display: block;"/><input class="default close" type="button" style="display: inline-block; margin: 0px 10px 10px 10px;" value="Close"/></div>').appendTo('body'); | |
var $display = $('.external_links'); | |
$display.find('input.close').click(function () { | |
$('.external_links').remove(); | |
}); | |
var uris = $(nyan).map(function (k, data) { | |
return data.filename + '\n' + 'http://storage.live.com/items/' + data.resid + '?filename=' + encodeURIComponent(data.filename); | |
}); | |
$display.find('textarea').val(Array.prototype.join.call(uris, '\n')); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Build bookmarklet with http://ted.mielczarek.org/code/mozilla/bookmarklet.html