Skip to content
Merged

V2.0 #43

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
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
max_line_length = 80
trim_trailing_whitespace = true

[package.json]
indent_size = 2
65 changes: 65 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,67 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# next.js build output
.next

build/

# xcode
xcuserdata/
*.xcuserstate
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## v2.0.0 (TBD)
- Complete overhaul/rewrite of the extension
- UI now lives in a page rather than popover
- Enables multiple, domain specific, scripts
- A lot more features of which will not be listed in the changelog

## v1.5.0 (2019-10-14)
- Enable code folding in editor
- Minor styling changes
Expand Down Expand Up @@ -33,4 +39,4 @@ Initial release using [Safari App Extensions](https://developer.apple.com/docume

## v1.0.0 (2018-12-01)

Initial release using [Safari Extension JS](https://developer.apple.com/documentation/safariextensions) - depreciated as of 2019-01-01
Initial release using [Safari Extension JS](https://developer.apple.com/documentation/safariextensions) - depreciated as of 2019-01-01
95 changes: 77 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,99 @@
# Userscripts for Safari
# Userscripts Safari

A simple, open-source, userscript editor for Safari.
An open-source userscript editor for Safari.

![Userscripts for Safari](/etc/screenshot.png)
![Userscripts Safari](/etc/screenshot.png)

## Installation

Install via [Mac App Store](https://itunes.apple.com/us/app/userscripts/id1463298887) or clone the project and build with Xcode.

**If you are looking for the old/simplified version of this extension, please check out [InjectJS](https://github.com/quoid/InjectJS).**

## Usage

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.
As of Version 2.0.0, this extension now supports multiple, domain specific, userscripts as well as supporting 2 different "userscript" types. It supports traditional javascript userscripts as well and css "userscripts" (or more commonly referred to as, userstyles).

Click the extension's toolbar button to open the extension UI.

If you don't feel like reading, visit [this folder](/etc/videos/) to watch some short and poorly made video tutorials.

**UI Overview**
![Userscripts Safari](/etc/ui-overview-01.png)
![Userscripts Safari](/etc/ui-overview-02.png)

1. **Create New Userscript Button** - Click this button to create a new userscript. You will be able to choose what type of userscript you would like to create (css or js)
1. **Userscript Filter** - You can use this to filter through your existing userscript. **Note**, this element filters by userscript title, not desription. It supports the following flags to help you filter more efficiently: `!js`, `!css`, `!disabled`, `!enabled`
1. **Userscript Toggle** - Toggling this element with enable/disable it's injection into webpages
1. **Editor** - The editor; the place where you write the code for the userscripts
1. **Download Button** - Click this to download a copy of your userscript
1. **Delete Button** - Click this to delete the userscript; *note:* deleted userscripts get put into your trash bin
1. **Settings Button** - Click this to open the settings modal
1. **Status Info** - Look here for status message pertaining to the currently opened userscript
1. **Discard/Save Buttons** - After editing a userscript, clicking on the "discard" button will remove any changes made since the userscript was loaded; clicking on the "save" button will save your changes to the userscript
1. **Sidebar** - Newly added/created scripts go here
1. **Settings Modal** - The various settings for the extension
1. **Global Blacklist** - Domain patterns entered here will be excluded from userscript injection; adding `*://*.*` to the global blacklist will turn off injection for all userscripts

## Userscript Metadata

Version 2.0.0 introduces the common practice of using userscript metadata to drive certain functionality. The currently supported fields will be listed below. There *are* plans to support more fields in future updates.

- `@name` **(required)** - This will be the name that displays in the sidebar and be used as the filename. You can not use the same name for multiple scripts of the same type.
- `@description` **(optional)** - Use this to describe what your userscript does. This will be displayed in the sidebar. There is a setting to hide userscript descriptions.
- `@match` **(optional)** - Domain match patterns; you can use several instances of this metafield if you'd like multiple domain matches. If you omit this metafield, the userscript will never run. View [this article for more information on constructing patterns](https://developer.chrome.com/extensions/match_patterns)
- `@exclude-match` **(optional)** - Domain patterns where you do *not* want the script to run

CSS Userscripts/styles can use the javascript metadata format or the Userstyle format. Both formats shown below are valid for **css** type.

```js
// ==UserScript==
// @name Example
// @description An example
// @match *://github.com/*
// @match *://*.github.com/*
// ==/UserScript==
```

```css
/* ==UserStyle==
@name Example
@description An example
@match *://github.com/*
@match *://*.github.com/*
==/UserStyle== */
```
## Notes & FAQs

**Do I need to use the extension's editor to create new userscripts or to edit existing?**

No; simply put your userscript in the extension's scripts folder. You can easily access this folder by clicking the link in the extension's settings modal option labelled "Save Location" or by visiting `~/Library/Containers/com.userscripts.macos.Userscripts-Extension/Data/Documents/scripts/`.

If you are adding a new userscript, before injection will occur, you must open the extension UI by clicking on the extension's toolbar button. If you are editing an existing userscript through your own editor, you should not need to open the ui for the changes to take effect.

**Can I change the location where my files are saved?**

Not yet, but this is planned in a future update.

**Are there any keyboard shortcuts?**

Here are some usage notes:
Currently there is only one keyboard shortcut - `cmd+s` to save changes. *Note:* normal shortcuts like `cmd+z`, `cmd+shift+z`, etc... like you would have on any other normal webpage should still function.

- `cmd + s` to save changes to the editor
- hinting is automatic, you can use the shortcut `ctrl + spacebar` to toggle hinting manually
- your code is saved into `~/Library/Containers/com.userscripts.macos.Userscripts-Extension/Data/Documents/userscript.js`
- this file can be edited with any code editor, however if the browser/extension is currently running, those changes won't be reflect in the include editor unless you reload the popover (right click `->` reload) - the changes **will** be injected whether or not you reload
- you can click the download icon to save your script file locally, without needing to navigate to this folder
- *note*, you will not be able to download the script on a blank tab
- you can toggle script injection on and off by clicking the "power" icon
- the code folding key command is `ctrl+q`
**I updated from Version 1.5.0, where did my previous userscript go?**

## Why?
Your previous userscript file *should* still exist after update. You can access its folder by clicking the link in the extension's settings modal option labelled "Save Location" or by visiting `~/Library/Containers/com.userscripts.macos.Userscripts-Extension/Data/Documents/`.

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 sign, even personal, `.safariextz` extensions, I needed a new way to dynamically create userscripts.
## Feedback & Support
If you need help doing something with this extension or you have an idea for an enhancement, please open an issue. Be sure to search current and closed issues before opening a new one.

There are other userscripts editors/managers for other browsers, and even good ones for Safari, but I wanted something very simple and *open-source*.
## Donate

## Privacy Policy
Userscripts does not collect any data from its users nor monitor activities or actions you perform within the application and extension. This means everything that you do with the application and extension is private to you and is never shared with the developers or third parties. Since there is no data collection, there is no data retention of any kind.

## License
## License

[GNU General Public License v3.0](/LICENSE)
Licensed under the [GNU General Public License v3.0](/LICENSE) license for all open source applications. A commercial license is required for all commercial applications.



22 changes: 0 additions & 22 deletions Userscripts Extension/Base.lproj/SafariExtensionViewController.xib

This file was deleted.

36 changes: 0 additions & 36 deletions Userscripts Extension/SafariExtensionHandler.swift

This file was deleted.

Loading