Created
February 18, 2019 22:32
-
-
Save ohmika/1877949eaedb946ce3c7c63fb1bd5757 to your computer and use it in GitHub Desktop.
Use the bookmarklet or JavaScript in order to download the shortcut file from an icloud.com link
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
javascript:%22use%20strict%22;%0Alet%20iCloudUrl%20%3D%20location.href;%0Alet%20apiUrl%20%3D%20iCloudUrl.replace(/%5C/shortcuts/g,%20%22/shortcuts/api/records%22);%0Alet%20iCloudApi%20%3D%20new%20XMLHttpRequest();%0AiCloudApi.open(%22GET%22,%20apiUrl);%0AiCloudApi.responseType%20%3D%20%22text%22;%0AiCloudApi.send();%0A%0AiCloudApi.onload%20%3D%20function()%20%7B%0A%20%20let%20apiResult%20%3D%20JSON.parse(iCloudApi.response);%0A%0A%20%20function%20saveData(url)%20%7B%0A%20%20%20%20let%20a%20%3D%20document.createElement(%22a%22);%0A%20%20%20%20document.body.appendChild(a);%0A%20%20%20%20a.style%20%3D%20%22display:%20none%22;%0A%0A%20%20%20%20a.href%20%3D%20url;%0A%20%20%20%20a.download;%0A%20%20%20%20a.click();%0A%20%20%20%20window.URL.revokeObjectURL(url);%0A%20%20%7D%0A%20%20let%20downloadURL%20%3D%20apiResult.fields.shortcut.value.downloadURL;%0A%20%20let%20shortcutName%20%3D%20apiResult.fields.name.value;%0A%20%20let%20finalURL%20%3D%20downloadURL.replace(%22$%7Bf%7D%22,%20shortcutName%20+%20%22.shortcut%22);%0A%20%20saveData(finalURL);%0A%7D; | |
"use strict"; | |
let iCloudUrl = location.href; | |
let apiUrl = iCloudUrl.replace(/\/shortcuts/g, "/shortcuts/api/records"); | |
let iCloudApi = new XMLHttpRequest(); | |
iCloudApi.open("GET", apiUrl); | |
iCloudApi.responseType = "text"; | |
iCloudApi.send(); | |
iCloudApi.onload = function() { | |
let apiResult = JSON.parse(iCloudApi.response); | |
function saveData(url) { | |
let a = document.createElement("a"); | |
document.body.appendChild(a); | |
a.style = "display: none"; | |
a.href = url; | |
a.download; | |
a.click(); | |
window.URL.revokeObjectURL(url); | |
} | |
let downloadURL = apiResult.fields.shortcut.value.downloadURL; | |
let shortcutName = apiResult.fields.name.value; | |
let finalURL = downloadURL.replace("${f}", shortcutName + ".shortcut"); | |
saveData(finalURL); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment