Skip to content
Merged
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
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog

## v2.0.0 (TBD)
## v2.0.1 (2020-07-27)
- @include/@exclude are now aliases for @match/@exlcude-match
- Display an error when browser is not supported

## v2.0.0 (2020-07-10)
- Complete overhaul/rewrite of the extension
- UI now lives in a page rather than popover
- Enables multiple, domain specific, scripts
Expand Down
6 changes: 6 additions & 0 deletions ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!-- Please fill out the below information before submitting your issue -->

_System Information:_
> macOS version:
> Userscripts version:
> Safari version:
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,14 @@ If you don't feel like reading, visit [this folder](/etc/videos/) to watch some

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
- `@name` - 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`- Use this to describe what your userscript does - this will be displayed in the sidebar - there is a setting to hide userscript descriptions
- `@match` - Domain match patterns - you can use several instances of this field if you'd like multiple domain matches - view [this article for more information on constructing patterns](https://developer.chrome.com/extensions/match_patterns)
- `@exclude-match` - Domain patterns where you do *not* want the script to run
- `@include` - An alias for `@match` - functions exactly like `@match`
- `@exclude` - An alias for `@exclude-match` - functions exactly like `@exclude-match`

**All userscripts need at least 1 `@match` or `@include` to run!**

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

Expand Down Expand Up @@ -85,6 +89,12 @@ Currently there is only one keyboard shortcut - `cmd+s` to save changes. *Note:*

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/`.

**How can I help development**

Any issue marked "help wanted" is actively seeking assistance. Please respond to those issues with feedback, guidance or offer coding assistance. Outside of those issues, it is fair to assume outstanding issues are already being worked on and new features are being actively developed.

If you are willing to beta test new versions of the extension, [you can sign up here](https://forms.gle/QB46uYQHVyCxULue9).

## 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.

Expand Down
4 changes: 2 additions & 2 deletions demo/index.html

Large diffs are not rendered by default.

18 changes: 16 additions & 2 deletions extension/Userscripts Extension/Functions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,15 @@ func updateScriptsData() -> [[String: Any]]? {
// can force unwrap b/c already checked match is not nil
matched = metadata["match"]!
}
// check for legacy include & exclude
if metadata["include"] != nil {
// can force unwrap b/c already checked match is not nil
matched.append(contentsOf: metadata["include"]!)
}
if metadata["exclude"] != nil {
// can force unwrap b/c already checked match is not nil
excluded.append(contentsOf: metadata["exclude"]!)
}
if !updateExcludesAndMatches(filename, excluded, matched) {
err("error updating matches in func updateScriptsData")
}
Expand Down Expand Up @@ -677,8 +686,13 @@ func saveScriptFile(_ scriptData: [String: String]) -> [String: String]? {
}

// update new excludes and matches
let excludes = metadata["exclude-match"] ?? []
let matches = metadata["match"] ?? []
var excludes = metadata["exclude-match"] ?? []
var matches = metadata["match"] ?? []
// check for legacy include & exclude
let includeLegacy = metadata["include"] ?? []
let excludeLegacy = metadata["exclude"] ?? []
matches.append(contentsOf: includeLegacy)
excludes.append(contentsOf: excludeLegacy)
if !updateExcludesAndMatches(newFilename, excludes, matches) {
err("failed to update manifest record for new filename when attempting to save script file")
}
Expand Down
4 changes: 2 additions & 2 deletions extension/Userscripts Extension/index.html

Large diffs are not rendered by default.

26 changes: 17 additions & 9 deletions extension/Userscripts.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1020;
LastUpgradeCheck = 1020;
LastUpgradeCheck = 1160;
ORGANIZATIONNAME = "Justin Wasack";
TargetAttributes = {
4A57B9EB227235CD008A9763 = {
Expand Down Expand Up @@ -403,16 +403,18 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_ENTITLEMENTS = "Userscripts Extension/Userscripts Extension.entitlements";
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 15;
CURRENT_PROJECT_VERSION = 16;
DEVELOPMENT_TEAM = J74Q8V8V8N;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = "Userscripts Extension/Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
"@executable_path/../../../../Frameworks",
);
MARKETING_VERSION = 2.0.0;
MARKETING_VERSION = 2.0.1;
PRODUCT_BUNDLE_IDENTIFIER = "com.userscripts.macos.Userscripts-Extension";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand All @@ -424,16 +426,18 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_ENTITLEMENTS = "Userscripts Extension/Userscripts Extension.entitlements";
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 15;
CURRENT_PROJECT_VERSION = 16;
DEVELOPMENT_TEAM = J74Q8V8V8N;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = "Userscripts Extension/Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
"@executable_path/../../../../Frameworks",
);
MARKETING_VERSION = 2.0.0;
MARKETING_VERSION = 2.0.1;
PRODUCT_BUNDLE_IDENTIFIER = "com.userscripts.macos.Userscripts-Extension";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand All @@ -447,16 +451,18 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = Userscripts/Userscripts.entitlements;
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 15;
CURRENT_PROJECT_VERSION = 16;
DEVELOPMENT_TEAM = J74Q8V8V8N;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = Userscripts/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 2.0.0;
MARKETING_VERSION = 2.0.1;
PRODUCT_BUNDLE_IDENTIFIER = com.userscripts.macos;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -469,16 +475,18 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = Userscripts/Userscripts.entitlements;
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 15;
CURRENT_PROJECT_VERSION = 16;
DEVELOPMENT_TEAM = J74Q8V8V8N;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = Userscripts/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 2.0.0;
MARKETING_VERSION = 2.0.1;
PRODUCT_BUNDLE_IDENTIFIER = com.userscripts.macos;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1030"
LastUpgradeVersion = "1160"
wasCreatedForAppExtension = "YES"
version = "2.0">
<BuildAction
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1030"
LastUpgradeVersion = "1160"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -27,8 +27,6 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
Expand All @@ -38,8 +36,8 @@
ReferencedContainer = "container:Userscripts.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -61,8 +59,6 @@
ReferencedContainer = "container:Userscripts.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
8 changes: 4 additions & 4 deletions extension/Userscripts/Userscripts.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
</dict>
</plist>
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</head>
<body class="init scripts-loading editor-loading">
<noscript>Please enable Javascript to use this app</noscript>
<div id="notify">This is a notify message</div>
<div id="notify"></div>
<div id="progress"></div>
<div id="wrapper">
{% include "sidebar.html" %}
Expand Down
2 changes: 1 addition & 1 deletion src/js/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ const ___settings = {
showInvisibles: "true",
tabSize: "4",
verbose: "true",
version: "2.0.0"
version: "2.0.1"
};

const ___parse = {
Expand Down
9 changes: 8 additions & 1 deletion src/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -976,5 +976,12 @@ window.onresize = function() {
};

window.onload = function() {
safari.extension.dispatchMessage("REQ_INIT_DATA");
try {
safari.extension.dispatchMessage("REQ_INIT_DATA");
} catch(e) {
const el = document.getElementById("notify");
el.innerText = "Safari object inaccessible, make sure Safari is version 13+";
el.style.display = "block";
console.error(e);
}
};
1 change: 1 addition & 0 deletions src/stylesheets/_main.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

/* z-indexes */
noscript { z-index: 99; }
#notify { z-index: 99;}
#appLoader { z-index: 98; }
#settings { z-index: 97; }
#progress {z-index: 96; }
Expand Down
13 changes: 1 addition & 12 deletions src/stylesheets/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,27 +58,16 @@ body:not(.init) #appLoader {
white-space: nowrap;
}

#notify,
noscript {
background-color: var(--color-red);
display: block;
font-size: 16px;
line-height: 16px;
padding: 8px;
text-align: center;
width: 100%;
}

#notify {
background-color: var(--color-yellow);
color: var(--bg-sidebar);
font-size: 14px;
font-weight: 600;
line-height: 16px;
padding: 4px;
text-align: center;
}

body:not(.notify) #notify {
display: none;
}

Expand Down