https://github.com/gorhill/ublock/wiki/Resources-Library#json-edit
If I'm not wrong, to do that we can just add aliases for these scriptlets in json-prune, json-prune-xhr-response and json-prune-fetch-response.
And change resolveJsonSyntaxMode to automatically detect JSONPath mode when propsToRemove starts with dot:
|
export function resolveJsonSyntaxMode( |
|
expression: string | undefined, |
|
mode: string | undefined, |
|
): ResolvedJsonSyntax { |
|
const LEGACY_MODE = 'legacy'; |
|
const JSONPATH_MODE = 'jsonpath'; |
|
const JSONPATH_GUARD = '[?'; |
|
const JSONPATH_ROOT_GUARD = '$'; |
|
|
|
const normalizedMode = typeof mode === 'string' ? mode.trim().toLowerCase() : ''; |
|
if (normalizedMode === LEGACY_MODE || normalizedMode === JSONPATH_MODE) { |
|
return { |
|
mode: normalizedMode as JsonPathSyntaxMode, |
|
}; |
|
} |
|
|
|
const normalizedExpression = typeof expression === 'string' ? expression.trim() : ''; |
|
if (normalizedExpression.startsWith(JSONPATH_ROOT_GUARD) || normalizedExpression.startsWith(JSONPATH_GUARD)) { |
|
return { |
|
mode: JSONPATH_MODE, |
|
}; |
|
} |
|
|
|
return { |
|
mode: LEGACY_MODE, |
|
}; |
|
} |
https://github.com/gorhill/ublock/wiki/Resources-Library#json-edit
If I'm not wrong, to do that we can just add aliases for these scriptlets in
json-prune,json-prune-xhr-responseandjson-prune-fetch-response.And change
resolveJsonSyntaxModeto automatically detectJSONPathmode whenpropsToRemovestarts with dot:Scriptlets/src/helpers/json-path-utils.ts
Lines 105 to 131 in f876415