2024-10-18 14:18:52 +00:00
|
|
|
export function parseAction(action: Action): string {
|
|
|
|
return `${action.domain}##${action.selector}##${action.name}${action.property ? `##${action.property}` : ''}`;
|
2024-08-03 10:58:19 +00:00
|
|
|
}
|
|
|
|
|
2024-10-18 14:18:52 +00:00
|
|
|
export function parseActionName(
|
|
|
|
action: Action
|
|
|
|
): Omit<Action, 'name'> & { readonly action: string } {
|
|
|
|
const { name, ...rest } = action;
|
|
|
|
|
|
|
|
return { action: name, ...rest };
|
|
|
|
}
|
|
|
|
|
|
|
|
export function toDeclarativeNetRequestRule(urlFilter: string, index: number) {
|
|
|
|
return {
|
|
|
|
action: {
|
|
|
|
type: 'block',
|
|
|
|
},
|
|
|
|
condition: {
|
|
|
|
resourceTypes: ['font', 'image', 'media', 'object', 'script', 'stylesheet', 'xmlhttprequest'],
|
|
|
|
urlFilter,
|
|
|
|
},
|
|
|
|
id: index + 1,
|
|
|
|
priority: 1,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface Action {
|
2024-08-03 10:58:19 +00:00
|
|
|
readonly domain: string;
|
2024-10-18 14:18:52 +00:00
|
|
|
readonly name: string;
|
2024-08-03 10:58:19 +00:00
|
|
|
readonly property?: string;
|
|
|
|
readonly selector: string;
|
|
|
|
}
|