You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+23-9Lines changed: 23 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -70,15 +70,16 @@ In the built output you will see these dramatic differences in the bundled code
70
70
To handle the difference in scope injection we expose multiple utilities which behave differently per browser in src/utils.js and `ContentFeature` base class. for Firefox the code exposed handles [xrays correctly](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Sharing_objects_with_page_scripts) without needing the features to be authored differently.
71
71
72
72
-`ContentFeature.defineProperty()`
73
-
- defineProperty(object, propertyName, descriptor) behaves the same as Object.defineProperty(object, propertyName, descriptor)
73
+
-`defineProperty(object, propertyName, descriptor)` behaves the same as `Object.defineProperty(object, propertyName, descriptor)`
74
74
- The difference is for Firefox we export the relevant functions so it can go across the xray
75
+
- Use this method if `Object.getOwnPropertyDescriptors(object).propertyName` should to exist in the supporting browser.
@@ -90,12 +91,25 @@ To handle the difference in scope injection we expose multiple utilities which b
90
91
returnawaitnativeImpl.call(this, queryObject)
91
92
})
92
93
```
93
-
94
-
- DDGProxy
95
-
- Behaves a lot like new window.Proxy with a few differences:
96
-
- has an overload function to actually apply the function to the native property.
94
+
-`DDGProxy`
95
+
- Behaves a lot like `new window.Proxy`with a few differences:
96
+
- has an `overload` method to actually apply the function to the native property.
97
97
- Stores the native original property in _native such that it can be called elsewhere if needed without going through the proxy.
98
-
- DDGReflect
98
+
- Triggers `addDebugFlag` if get/apply is called.
99
+
- Sends debugging messaging if debug is enabled.
100
+
- Allows for remotely disabling the override based on script URL via `shouldExemptMethod`.
101
+
- Fixes `value.toString()` to appear like it was defined natively.
102
+
- Example usage:
103
+
```JavaScript
104
+
const historyMethodProxy = new DDGProxy(this, History.prototype, 'pushState', {
105
+
apply (target, thisArg, args) {
106
+
applyRules(activeRules)
107
+
returnDDGReflect.apply(target, thisArg, args)
108
+
}
109
+
})
110
+
historyMethodProxy.overload()
111
+
```
112
+
-`DDGReflect`
99
113
- Calls into wrappedJSObject.Reflectfor Firefox but otherwise exactly the same as [window.Reflect](Sources/BrowserServicesKit/UserScript/ContentScopeUserScript.swift)
0 commit comments