From 71f0a060d1a1daac2ad40cba0ef5f8ee4a713970 Mon Sep 17 00:00:00 2001 From: quoid Date: Fri, 28 Oct 2022 16:41:20 -0400 Subject: [PATCH 1/4] refactor: remove `"use strict"` statement from code wrap --- extension/Userscripts Extension/Resources/content.js | 1 - 1 file changed, 1 deletion(-) diff --git a/extension/Userscripts Extension/Resources/content.js b/extension/Userscripts Extension/Resources/content.js index eb39981f..5973d9f0 100644 --- a/extension/Userscripts Extension/Resources/content.js +++ b/extension/Userscripts Extension/Resources/content.js @@ -241,7 +241,6 @@ function processJS(userscript) { function wrapCode(preCode, code, filename) { return ` (function() { - "use strict"; ${preCode} (function() { const US_filename = "${filename}"; From 9b4d5404ee3aa036c23e4012b07f6acfe4b11e50 Mon Sep 17 00:00:00 2001 From: quoid Date: Fri, 28 Oct 2022 16:43:26 -0400 Subject: [PATCH 2/4] fix: add `none` as a valid `@grant` value in editor --- extension/Userscripts Extension/Resources/page.html | 2 +- extension/Userscripts Extension/Resources/page.js | 3 ++- src/page/utils.js | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/extension/Userscripts Extension/Resources/page.html b/extension/Userscripts Extension/Resources/page.html index f837f97d..babce656 100644 --- a/extension/Userscripts Extension/Resources/page.html +++ b/extension/Userscripts Extension/Resources/page.html @@ -1 +1 @@ -Userscripts Safari
\ No newline at end of file +Userscripts Safari
\ No newline at end of file diff --git a/extension/Userscripts Extension/Resources/page.js b/extension/Userscripts Extension/Resources/page.js index 90ac3077..94d08d13 100644 --- a/extension/Userscripts Extension/Resources/page.js +++ b/extension/Userscripts Extension/Resources/page.js @@ -1143,7 +1143,8 @@ var JSHINT;"undefined"==typeof window&&(window={}),function(){var f=function u(o "GM.getTab", "GM.saveTab", "GM_xmlhttpRequest", - "GM.xmlHttpRequest" + "GM.xmlHttpRequest", + "none" ]); const validKeys = new Set([ diff --git a/src/page/utils.js b/src/page/utils.js index 2de5a96f..27062c0a 100644 --- a/src/page/utils.js +++ b/src/page/utils.js @@ -153,7 +153,8 @@ export const validGrants = new Set([ "GM.getTab", "GM.saveTab", "GM_xmlhttpRequest", - "GM.xmlHttpRequest" + "GM.xmlHttpRequest", + "none" ]); export const validKeys = new Set([ From 5b77319a2f2252913e8da107ad7d7a9d41a2e54e Mon Sep 17 00:00:00 2001 From: quoid Date: Fri, 28 Oct 2022 16:52:33 -0400 Subject: [PATCH 3/4] fix: properly wrap context-menu userscripts --- .../Userscripts Extension/Resources/content.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/extension/Userscripts Extension/Resources/content.js b/extension/Userscripts Extension/Resources/content.js index 5973d9f0..0a1b63e4 100644 --- a/extension/Userscripts Extension/Resources/content.js +++ b/extension/Userscripts Extension/Resources/content.js @@ -330,9 +330,11 @@ browser.runtime.sendMessage({name: "REQ_USERSCRIPTS"}, response => { } // save response locally in case CSP events occur data = response; + // combine regular and context-menu scripts + const scripts = [...data.files.js, ...data.files.menu]; // loop through each userscript and prepare for processing - for (let i = 0; i < data.files.js.length; i++) { - const userscript = data.files.js[i]; + for (let i = 0; i < scripts.length; i++) { + const userscript = scripts[i]; userscript.preCode = ""; // pass references to the api methods as needed const gmMethods = []; @@ -450,7 +452,13 @@ browser.runtime.onMessage.addListener((request, sender, sendResponse) => { const item = data.files.menu[i]; if (item.scriptObject.filename === filename) { console.info(`Injecting ${filename} %c(js)`, "color: #fff600"); - sendResponse({code: item.code}); + sendResponse({ + code: wrapCode( + item.preCode, + item.code, + filename + ) + }); return; } } From 3066a2b37fa49784ae0eeb5d9914cc68df62a1ef Mon Sep 17 00:00:00 2001 From: quoid Date: Fri, 28 Oct 2022 16:53:06 -0400 Subject: [PATCH 4/4] bump versions and build --- .../Resources/manifest.json | 2 +- .../Userscripts.xcodeproj/project.pbxproj | 32 +++++++++---------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/extension/Userscripts Extension/Resources/manifest.json b/extension/Userscripts Extension/Resources/manifest.json index 3a1e6a6b..f23a76d5 100644 --- a/extension/Userscripts Extension/Resources/manifest.json +++ b/extension/Userscripts Extension/Resources/manifest.json @@ -4,7 +4,7 @@ "default_locale": "en", "name": "__MSG_extension_name__", "description": "__MSG_extension_description__", - "version": "4.3.1", + "version": "4.3.2", "icons": { "48": "images/icon-48.png", "96": "images/icon-96.png", diff --git a/extension/Userscripts.xcodeproj/project.pbxproj b/extension/Userscripts.xcodeproj/project.pbxproj index 6d6ab184..189526f2 100644 --- a/extension/Userscripts.xcodeproj/project.pbxproj +++ b/extension/Userscripts.xcodeproj/project.pbxproj @@ -663,7 +663,7 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; CODE_SIGN_ENTITLEMENTS = "Userscripts-iOS/Userscripts-iOS.entitlements"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 35; + CURRENT_PROJECT_VERSION = 37; DEVELOPMENT_TEAM = J74Q8V8V8N; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = "Userscripts-iOS/Info.plist"; @@ -679,7 +679,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.3.1; + MARKETING_VERSION = 1.3.2; OTHER_LDFLAGS = ( "-framework", SafariServices, @@ -704,7 +704,7 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; CODE_SIGN_ENTITLEMENTS = "Userscripts-iOS/Userscripts-iOS.entitlements"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 35; + CURRENT_PROJECT_VERSION = 37; DEVELOPMENT_TEAM = J74Q8V8V8N; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = "Userscripts-iOS/Info.plist"; @@ -720,7 +720,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.3.1; + MARKETING_VERSION = 1.3.2; OTHER_LDFLAGS = ( "-framework", SafariServices, @@ -743,7 +743,7 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; CODE_SIGN_ENTITLEMENTS = "Userscripts-iOS Extension/Userscripts-iOS Extension.entitlements"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 35; + CURRENT_PROJECT_VERSION = 37; DEVELOPMENT_TEAM = J74Q8V8V8N; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = "Userscripts-iOS Extension/Info.plist"; @@ -755,7 +755,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.3.1; + MARKETING_VERSION = 1.3.2; OTHER_LDFLAGS = ( "-framework", SafariServices, @@ -776,7 +776,7 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; CODE_SIGN_ENTITLEMENTS = "Userscripts-iOS Extension/Userscripts-iOS Extension.entitlements"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 35; + CURRENT_PROJECT_VERSION = 37; DEVELOPMENT_TEAM = J74Q8V8V8N; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = "Userscripts-iOS Extension/Info.plist"; @@ -788,7 +788,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 1.3.1; + MARKETING_VERSION = 1.3.2; OTHER_LDFLAGS = ( "-framework", SafariServices, @@ -929,7 +929,7 @@ CODE_SIGN_ENTITLEMENTS = "Userscripts Extension/Userscripts Extension.entitlements"; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 62; + CURRENT_PROJECT_VERSION = 64; DEVELOPMENT_TEAM = J74Q8V8V8N; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = "Userscripts Extension/Info.plist"; @@ -939,7 +939,7 @@ "@executable_path/../../../../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 12.0; - MARKETING_VERSION = 4.3.1; + MARKETING_VERSION = 4.3.2; PRODUCT_BUNDLE_IDENTIFIER = "com.userscripts.macos.Userscripts-Extension"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; @@ -953,7 +953,7 @@ CODE_SIGN_ENTITLEMENTS = "Userscripts Extension/Userscripts Extension.entitlements"; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 62; + CURRENT_PROJECT_VERSION = 64; DEVELOPMENT_TEAM = J74Q8V8V8N; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = "Userscripts Extension/Info.plist"; @@ -963,7 +963,7 @@ "@executable_path/../../../../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 12.0; - MARKETING_VERSION = 4.3.1; + MARKETING_VERSION = 4.3.2; PRODUCT_BUNDLE_IDENTIFIER = "com.userscripts.macos.Userscripts-Extension"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; @@ -980,7 +980,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 62; + CURRENT_PROJECT_VERSION = 64; DEVELOPMENT_TEAM = J74Q8V8V8N; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = Userscripts/Info.plist; @@ -989,7 +989,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 12.0; - MARKETING_VERSION = 4.3.1; + MARKETING_VERSION = 4.3.2; PRODUCT_BUNDLE_IDENTIFIER = com.userscripts.macos; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; @@ -1005,7 +1005,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 62; + CURRENT_PROJECT_VERSION = 64; DEVELOPMENT_TEAM = J74Q8V8V8N; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = Userscripts/Info.plist; @@ -1014,7 +1014,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 12.0; - MARKETING_VERSION = 4.3.1; + MARKETING_VERSION = 4.3.2; PRODUCT_BUNDLE_IDENTIFIER = com.userscripts.macos; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0;