Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save TheMetaphysicalCrook/60e97da2ea160b99730aaeccf4ef3ed4 to your computer and use it in GitHub Desktop.
Save TheMetaphysicalCrook/60e97da2ea160b99730aaeccf4ef3ed4 to your computer and use it in GitHub Desktop.
Add "Preview" button to iOS shortcut's iCloud links, linking to preview.scpl.dev (plus cosmetic changes to the last)
// ==UserScript==
// @name shortcut-preview
// @namespace https://www.atnbueno.com/
// @match https://preview.scpl.dev/*
// @match https://www.icloud.com/shortcuts/*
// @version 1.2
// @grant none
// ==/UserScript==
(function () {
"use strict";
// adds "Preview" button to iCloud shortcut links ("Vista previa" in Spanish)
if (location.host == "www.icloud.com") {
let previewLink = document.createElement("a"), previewText;
if (navigator.language.slice(0, 2) == "es") {
previewText = "Vista previa"
} else {
previewText = "Preview"
}
previewLink.appendChild(document.createTextNode(previewText));
previewLink.href = "https://preview.scpl.dev/?shortcut=" + location.href;
document.getElementById("shortcut-links").appendChild(previewLink);
} else if (location.host == "preview.scpl.dev") {
// changes cosmetic details in the shortcut preview
var stylesheet = document.createElement("style");
stylesheet.textContent = `
header {
font-family: "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
margin: 2em;
}
header p.versionerror {
color: darkred;
margin: 1em auto;
max-width: 576px;
}
header p:not(.versionerror) {
background: #0169D9;
border-radius: 8px;
display: inline-block;
margin: 1em;
width: 10em;
padding: 10px;
}
header p:hover {
opacity: 0.9;
}
header a {
color: white;
font-size: 110%;
text-decoration: none;
}
header img {
border-radius: 16px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, .14);
max-width: 12em;
}
div.styles_actionBlockWrapper__3gC_8 {
max-width: 600px;
}
.styles_field__tuaih.styles_multiline__1vzVg {
height: auto !important;
}
`;
document.documentElement.appendChild(stylesheet);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment