Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"arrowParens": "always",
"printWidth": 140,
"proseWrap": "never",
"semi": true,
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": true
}
502 changes: 304 additions & 198 deletions index.html

Large diffs are not rendered by default.

52 changes: 26 additions & 26 deletions install.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
const url = 'https://scriptdu.de/script.js';
const url = "https://scriptdu.de/script.js";

class ScriptDudeInstaller {
constructor(hoehe, breite) {
this.fileManager = FileManager.iCloud()
this.documentsDirectory = this.fileManager.documentsDirectory()
}
hashCode(input) {
return Array.from(input).reduce((accumulator, currentChar) => Math.imul(31, accumulator) + currentChar.charCodeAt(0), 0)
}
async installScript(name, sourceUrl, documentationUrl, icon, color, showMessage) {
let filePath = this.fileManager.joinPath(this.documentsDirectory, name + '.js');
let req = new Request(sourceUrl);
let code = await req.loadString();
let hash = this.hashCode(code);
let codeToStore = Data.fromString(`// Variables used by Scriptable.\n// These must be at the very top of the file. Do not edit.\n// icon-color: ${color}; icon-glyph: ${icon};\n// This script was downloaded using ScriptDude.\n// Do not remove these lines, if you want to benefit from automatic updates.\n// source: ${sourceUrl}; docs: ${documentationUrl}; hash: ${hash};\n\n${code}`);
this.fileManager.write(filePath, codeToStore);
let selfFilePath = this.fileManager.joinPath(this.documentsDirectory, Script.name() + '.js');
this.fileManager.remove(selfFilePath);
let callback = new CallbackURL("scriptable:///run");
callback.addParameter("scriptName", "ScriptDude");
callback.open();
}
constructor(hoehe, breite) {
this.fileManager = FileManager.iCloud();
this.documentsDirectory = this.fileManager.documentsDirectory();
}

hashCode(input) {
return Array.from(input).reduce((accumulator, currentChar) => Math.imul(31, accumulator) + currentChar.charCodeAt(0), 0);
}

async installScript(name, sourceUrl, documentationUrl, icon, color, showMessage) {
let filePath = this.fileManager.joinPath(this.documentsDirectory, name + ".js");
let req = new Request(sourceUrl);
let code = await req.loadString();
let hash = this.hashCode(code);
let codeToStore = Data.fromString(
`// Variables used by Scriptable.\n// These must be at the very top of the file. Do not edit.\n// icon-color: ${color}; icon-glyph: ${icon};\n// This script was downloaded using ScriptDude.\n// Do not remove these lines, if you want to benefit from automatic updates.\n// source: ${sourceUrl}; docs: ${documentationUrl}; hash: ${hash};\n\n${code}`
);
this.fileManager.write(filePath, codeToStore);
let selfFilePath = this.fileManager.joinPath(this.documentsDirectory, Script.name() + ".js");
this.fileManager.remove(selfFilePath);
let callback = new CallbackURL("scriptable:///run");
callback.addParameter("scriptName", "ScriptDude");
callback.open();
}
}

await new ScriptDudeInstaller().installScript('ScriptDude', url, 'https://scriptdu.de/', 'user-astronaut', 'blue', false);
await new ScriptDudeInstaller().installScript("ScriptDude", url, "https://scriptdu.de/", "user-astronaut", "blue", false);
Loading