Skip to content

Commit 6cf5128

Browse files
committed
v1.0 upload
1 parent 6aeb244 commit 6cf5128

32 files changed

Lines changed: 13980 additions & 1 deletion

README.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,33 @@
1-
# userscripts
1+
# Userscripts for Safari
2+
3+
A simple, open-source, userscript editor for Safari.
4+
5+
![Userscripts for Safari](/etc/screenshot-large.png)
6+
7+
## Installation
8+
9+
With the changes to Safari 12 and .safariextz-style extensions, the only way to install this extension is through the [Safari Extension Gallery](https://safari-extensions.apple.com) (this link will be updated once the extension is live on the gallery).
10+
11+
## Usage
12+
13+
Using the extension is simple. You can open the editor by clicking on the the toolbar button. Any code you write will be injected into every website you visit.
14+
15+
Here are some usage notes:
16+
17+
- `cmd + s` to save changes to the editor
18+
- hinting is automatic, you can use the shortcut `ctrl + spacebar` to toggle hinting manually
19+
- your code is saved into `localStorage` of the extension, if you clear the `localStorage` of your browser, you will remove your saved code
20+
- you can click the download icon to save your scripts locally
21+
22+
## Why?
23+
24+
With the depreciation of `.safariextz` style extension in Safari 12, I wanted a way to quickly and easily create some "quality of life" userscripts. Since it's no longer possible to create and signed, even personal, `.safariextz` extensions, I needed a new way to dynamically create userscripts.
25+
26+
There are other userscripts editors/managers for other browsers, and even good ones for Safari, but I wanted something very simple and *open-source*.
27+
28+
## License
29+
30+
[GNU General Public License v3.0](/LICENSE)
31+
32+
33+

etc/screenshot-large.png

201 KB
Loading

etc/screenshot.png

130 KB
Loading

etc/sketch/icon.sketch

30.4 KB
Binary file not shown.

etc/sketch/screenshot.sketch

1010 KB
Binary file not shown.

update.plist

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>Extension Updates</key>
6+
<array>
7+
<dict>
8+
<key>CFBundleIdentifier</key>
9+
<string>com.quoid.userscripts</string>
10+
<key>Developer Identifier</key>
11+
<string>J74Q8V8V8N</string>
12+
<key>CFBundleVersion</key>
13+
<string>1.0.0</string>
14+
<key>CFBundleShortVersionString</key>
15+
<string>1.0.0</string>
16+
<key>URL</key>
17+
<string>https://raw.githubusercontent.com/quoid/userscripts/master/userscripts.safariextz</string>
18+
</dict>
19+
</array>
20+
</dict>
21+
</plist>
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>Author</key>
6+
<string>Justin Wasack</string>
7+
<key>Builder Version</key>
8+
<string>14606.2.104.1.1</string>
9+
<key>CFBundleDisplayName</key>
10+
<string>Userscripts</string>
11+
<key>CFBundleIdentifier</key>
12+
<string>com.quoid.userscripts</string>
13+
<key>CFBundleInfoDictionaryVersion</key>
14+
<string>6.0</string>
15+
<key>CFBundleShortVersionString</key>
16+
<string>1.0</string>
17+
<key>CFBundleVersion</key>
18+
<string>1</string>
19+
<key>Chrome</key>
20+
<dict>
21+
<key>Global Page</key>
22+
<string>global.html</string>
23+
<key>Popovers</key>
24+
<array>
25+
<dict>
26+
<key>Filename</key>
27+
<string>popover.html</string>
28+
<key>Height</key>
29+
<integer>600</integer>
30+
<key>Identifier</key>
31+
<string>userscripts_popover</string>
32+
<key>Width</key>
33+
<integer>700</integer>
34+
</dict>
35+
</array>
36+
<key>Toolbar Items</key>
37+
<array>
38+
<dict>
39+
<key>Identifier</key>
40+
<string>userscripts_button</string>
41+
<key>Image</key>
42+
<string>include/button.png</string>
43+
<key>Include By Default</key>
44+
<true/>
45+
<key>Label</key>
46+
<string>Userscripts</string>
47+
<key>Palette Label</key>
48+
<string>Userscripts</string>
49+
<key>Popover</key>
50+
<string>userscripts_popover</string>
51+
<key>Tool Tip</key>
52+
<string>Open Userscripts</string>
53+
</dict>
54+
</array>
55+
</dict>
56+
<key>Content</key>
57+
<dict>
58+
<key>Scripts</key>
59+
<dict>
60+
<key>Start</key>
61+
<array>
62+
<string>include/js/start.js</string>
63+
</array>
64+
</dict>
65+
</dict>
66+
<key>Description</key>
67+
<string>A simple, open-source, userscript editor for Safari</string>
68+
<key>DeveloperIdentifier</key>
69+
<string>J74Q8V8V8N</string>
70+
<key>ExtensionInfoDictionaryVersion</key>
71+
<string>1.0</string>
72+
<key>Permissions</key>
73+
<dict>
74+
<key>Website Access</key>
75+
<dict>
76+
<key>Include Secure Pages</key>
77+
<true/>
78+
<key>Level</key>
79+
<string>All</string>
80+
</dict>
81+
</dict>
82+
<key>Update Manifest URL</key>
83+
<string>https://raw.githubusercontent.com/quoid/userscripts/master/update.plist</string>
84+
<key>Website</key>
85+
<string>https://github.com/quoid/userscripts</string>
86+
</dict>
87+
</plist>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head></head>
4+
<body>
5+
<script src="./include/js/global.js"></script>
6+
</body>
7+
</html>
27.3 KB
Loading
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
2+
// Distributed under an MIT license: https://codemirror.net/LICENSE
3+
4+
(function(mod) {
5+
if (typeof exports == "object" && typeof module == "object") // CommonJS
6+
mod(require("../../lib/codemirror"));
7+
else if (typeof define == "function" && define.amd) // AMD
8+
define(["../../lib/codemirror"], mod);
9+
else // Plain browser env
10+
mod(CodeMirror);
11+
})(function(CodeMirror) {
12+
"use strict";
13+
var WRAP_CLASS = "CodeMirror-activeline";
14+
var BACK_CLASS = "CodeMirror-activeline-background";
15+
var GUTT_CLASS = "CodeMirror-activeline-gutter";
16+
17+
CodeMirror.defineOption("styleActiveLine", false, function(cm, val, old) {
18+
var prev = old == CodeMirror.Init ? false : old;
19+
if (val == prev) return
20+
if (prev) {
21+
cm.off("beforeSelectionChange", selectionChange);
22+
clearActiveLines(cm);
23+
delete cm.state.activeLines;
24+
}
25+
if (val) {
26+
cm.state.activeLines = [];
27+
updateActiveLines(cm, cm.listSelections());
28+
cm.on("beforeSelectionChange", selectionChange);
29+
}
30+
});
31+
32+
function clearActiveLines(cm) {
33+
for (var i = 0; i < cm.state.activeLines.length; i++) {
34+
cm.removeLineClass(cm.state.activeLines[i], "wrap", WRAP_CLASS);
35+
cm.removeLineClass(cm.state.activeLines[i], "background", BACK_CLASS);
36+
cm.removeLineClass(cm.state.activeLines[i], "gutter", GUTT_CLASS);
37+
}
38+
}
39+
40+
function sameArray(a, b) {
41+
if (a.length != b.length) return false;
42+
for (var i = 0; i < a.length; i++)
43+
if (a[i] != b[i]) return false;
44+
return true;
45+
}
46+
47+
function updateActiveLines(cm, ranges) {
48+
var active = [];
49+
for (var i = 0; i < ranges.length; i++) {
50+
var range = ranges[i];
51+
var option = cm.getOption("styleActiveLine");
52+
if (typeof option == "object" && option.nonEmpty ? range.anchor.line != range.head.line : !range.empty())
53+
continue
54+
var line = cm.getLineHandleVisualStart(range.head.line);
55+
if (active[active.length - 1] != line) active.push(line);
56+
}
57+
if (sameArray(cm.state.activeLines, active)) return;
58+
cm.operation(function() {
59+
clearActiveLines(cm);
60+
for (var i = 0; i < active.length; i++) {
61+
cm.addLineClass(active[i], "wrap", WRAP_CLASS);
62+
cm.addLineClass(active[i], "background", BACK_CLASS);
63+
cm.addLineClass(active[i], "gutter", GUTT_CLASS);
64+
}
65+
cm.state.activeLines = active;
66+
});
67+
}
68+
69+
function selectionChange(cm, sel) {
70+
updateActiveLines(cm, sel.ranges);
71+
}
72+
});

0 commit comments

Comments
 (0)