Instance Method

setContentBlocker

Loads content-blocking rules from an object.

Declaration

void setContentBlocker(in any contentBlocker, in function callback);

Parameters

contentBlocker

A JSON string or JSON object containing content-blocking rules.

callback

The callback to invoke after successfully loading the content-blocking rules.

Discussion

This method lets you configure your content-blocking rules based on user input, overriding any previous calls to the setContentBlocker method and any content blocker set in Info.plist. Passing null or undefined will clear any content blocker the extension has previously set. The callback receives a JavaScript error object that describes any errors that occurred while compiling the content blocker. The setContentBlocker method only affects future page loads.

See Dynamically Changing Content-Blocking Rules.