diff --git a/CHANGELOG.md b/CHANGELOG.md index c50d59eb..3500e741 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md new file mode 100644 index 00000000..426b1deb --- /dev/null +++ b/ISSUE_TEMPLATE.md @@ -0,0 +1,6 @@ + + +_System Information:_ +> macOS version: +> Userscripts version: +> Safari version: diff --git a/README.md b/README.md index 700f3caa..f19b07a5 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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. diff --git a/demo/index.html b/demo/index.html index d306afe0..1bae25da 100644 --- a/demo/index.html +++ b/demo/index.html @@ -1,4 +1,4 @@ -Userscripts Safari
This is a notify message
css
js
init
init
+Userscripts Safari
css
js
init
init
@@ -19,4 +19,4 @@ --> - \ No newline at end of file + \ No newline at end of file diff --git a/extension/Userscripts Extension/Functions.swift b/extension/Userscripts Extension/Functions.swift index b27f2737..b5e1235a 100644 --- a/extension/Userscripts Extension/Functions.swift +++ b/extension/Userscripts Extension/Functions.swift @@ -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") } @@ -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") } diff --git a/extension/Userscripts Extension/index.html b/extension/Userscripts Extension/index.html index e6bf3a12..f8a36395 100644 --- a/extension/Userscripts Extension/index.html +++ b/extension/Userscripts Extension/index.html @@ -1,4 +1,4 @@ -Userscripts Safari
This is a notify message
css
js
init
init
+Userscripts Safari
css
js
init
init
@@ -19,4 +19,4 @@ --> - \ No newline at end of file + \ No newline at end of file diff --git a/extension/Userscripts.xcodeproj/project.pbxproj b/extension/Userscripts.xcodeproj/project.pbxproj index d27492d7..f40058b0 100644 --- a/extension/Userscripts.xcodeproj/project.pbxproj +++ b/extension/Userscripts.xcodeproj/project.pbxproj @@ -185,7 +185,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 1020; - LastUpgradeCheck = 1020; + LastUpgradeCheck = 1160; ORGANIZATIONNAME = "Justin Wasack"; TargetAttributes = { 4A57B9EB227235CD008A9763 = { @@ -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; @@ -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; @@ -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; @@ -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; diff --git a/extension/Userscripts.xcodeproj/xcshareddata/xcschemes/Userscripts Extension.xcscheme b/extension/Userscripts.xcodeproj/xcshareddata/xcschemes/Userscripts Extension.xcscheme index 295b057e..e10116aa 100644 --- a/extension/Userscripts.xcodeproj/xcshareddata/xcschemes/Userscripts Extension.xcscheme +++ b/extension/Userscripts.xcodeproj/xcshareddata/xcschemes/Userscripts Extension.xcscheme @@ -1,6 +1,6 @@ - - - - + + - - - com.apple.security.app-sandbox - - com.apple.security.files.user-selected.read-only - + com.apple.security.app-sandbox + + com.apple.security.files.user-selected.read-only + diff --git a/package-lock.json b/package-lock.json index 5a01fb1f..b9c76d00 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2954,9 +2954,9 @@ } }, "lodash": { - "version": "4.17.15", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", + "version": "4.17.19", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.19.tgz", + "integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==", "dev": true }, "lower-case": { @@ -5395,9 +5395,9 @@ } }, "websocket-extensions": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/websocket-extensions/-/websocket-extensions-0.1.3.tgz", - "integrity": "sha512-nqHUnMXmBzT0w570r2JpJxfiSD1IzoI+HGVdd3aZ0yNi3ngvQ4jv1dtHt5VGxfI2yj5yqImPhOK4vmIh2xMbGg==", + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/websocket-extensions/-/websocket-extensions-0.1.4.tgz", + "integrity": "sha512-OqedPIGOfsDlo31UNwYbCFMSaO9m9G/0faIHj5/dZFDMFqPTcx6UwqyOy3COEaEOg/9VsGIpdqn62W5KhoKSpg==", "dev": true }, "which": { diff --git a/src/index.html b/src/index.html index cdae3806..b921eabf 100644 --- a/src/index.html +++ b/src/index.html @@ -18,7 +18,7 @@ -
This is a notify message
+
{% include "sidebar.html" %} diff --git a/src/js/dev.js b/src/js/dev.js index ef31c453..4dc64462 100644 --- a/src/js/dev.js +++ b/src/js/dev.js @@ -195,7 +195,7 @@ const ___settings = { showInvisibles: "true", tabSize: "4", verbose: "true", - version: "2.0.0" + version: "2.0.1" }; const ___parse = { diff --git a/src/js/main.js b/src/js/main.js index b7a6be69..1173ef0f 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -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); + } }; diff --git a/src/stylesheets/_main.css b/src/stylesheets/_main.css index e054210e..a210d416 100644 --- a/src/stylesheets/_main.css +++ b/src/stylesheets/_main.css @@ -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; } diff --git a/src/stylesheets/global.css b/src/stylesheets/global.css index 34cbd5cc..81586012 100644 --- a/src/stylesheets/global.css +++ b/src/stylesheets/global.css @@ -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; }