experiments

This commit is contained in:
eevee committed 2025-06-18 00:51:01 +03:00
1 parent 92e6cc7900
commit a994490604
36 files changed
+264 -64

No files matched your search

@@ -0,0 +1,5 @@
import Foundation
@objc protocol SPTSharingSDKDestination {
func destinationID() -> String
}
@@ -0,0 +1,25 @@
import Orion
import UIKit
struct InstgramDestinationGroup: HookGroup { }
class SPTSharingSDKHook: ClassHook<NSObject> {
typealias Group = InstgramDestinationGroup
static let targetName = "SPTSharingSDK"
func canHandleShareDestination(_ destination: SPTSharingSDKDestination) -> Bool {
if destination.destinationID().contains("instagram") {
return true
}
return orig.canHandleShareDestination(destination)
}
}
class FoundationImplPropertiesHook: ClassHook<NSObject> {
typealias Group = InstgramDestinationGroup
static let targetName = "SPTShare_FoundationImplProperties"
func isInstagramStoriesCanvasSharingEnabled() -> Bool { return true }
func isInstagramDirectMessageSharingEnabled() -> Bool { return true }
}
@@ -0,0 +1,38 @@
import Orion
import UIKit
import UniformTypeIdentifiers
class UIApplicationLiveContainerSharingHook: ClassHook<UIApplication> {
func openURL(
_ url: URL,
options: [String: Any],
completionHandler: (@MainActor (ObjCBool) -> Void)?
) {
if UserDefaults.experimentsOptions.liveContainerSharing, !target.canOpenURL(url) {
UIPasteboard.general.addItems([[UTType.url.identifier: url]])
let data = url.dataRepresentation
let liveContainerUrl = URL(string: "livecontainer://open-web-page?url=\(data.base64EncodedString())")!
orig.openURL(
liveContainerUrl,
options: options,
completionHandler: { success in
completionHandler?(true)
if !success.boolValue {
PopUpHelper.showPopUp(
delayed: false,
message: "could_not_share_popup".localized,
buttonText: "OK".uiKitLocalized
)
}
}
)
return
}
orig.openURL(url, options: options, completionHandler: completionHandler)
}
}
@@ -0,0 +1,12 @@
import Foundation
extension UserDefaults {
@UserDefault(
key: "experimentsOptions",
defaultValue: ExperimentsOptions(
showInstagramDestination: false,
liveContainerSharing: true
)
)
static var experimentsOptions
}
@@ -0,0 +1,4 @@
struct ExperimentsOptions: Codable, Equatable {
var showInstagramDestination: Bool
var liveContainerSharing: Bool
}