# eric6.WebBrowser.AdBlock.AdBlockManager

Module implementing the AdBlock manager.

### Global Attributes

None

### Classes

AdBlockManager | Class implementing the AdBlock manager.

### Functions

None

## AdBlockManager

Class implementing the AdBlock manager.

### Signals

enabledChanged(enabled)
  emitted to indicate a change of the enabled state
requiredSubscriptionLoaded(subscription)
  emitted to indicate loading of a required subscription is finished (AdBlockSubscription)
rulesChanged()
  emitted after some rule has changed

### Derived from

QObject

### Class Attributes

None

### Class Methods

None

### Methods

AdBlockManager | Constructor
__canBeBlocked | Private method to check, if the given URL could be blocked (i.e.
__customSubscriptionLocation | Private method to generate the path for custom subscriptions.
__customSubscriptionUrl | Private method to generate the URL for custom subscriptions.
__loadSubscriptions | Private method to load the set of subscriptions.
__rulesChanged | Private slot handling a change of the AdBlock rules.
__updateMatcher | Private slot to update the adblock matcher.
addException | Public method to add an exception.
addSubscription | Public method to add an AdBlock subscription.
addSubscriptionFromUrl | Public method to ad an AdBlock subscription given the abp URL.
block | Public method to check, if a request should be blocked.
canRunOnScheme | Public method to check, if AdBlock can be performed on the scheme.
close | Public method to close the open search engines manager.
customRules | Public method to get a subscription for custom rules.
elementHidingRules | Public method to get the element hiding rules.
elementHidingRulesForDomain | Public method to get the element hiding rules for a domain.
exceptions | Public method to get a list of excepted hosts.
getDefaultSubscriptionUrl | Public method to get the default subscription URL.
getRequiresSubscriptions | Public method to get a list of subscriptions, that require the given one.
isEnabled | Public method to check, if blocking ads is enabled.
isHostExcepted | Public slot to check, if a host is excepted.
load | Public method to load the AdBlock subscriptions.
loadRequiredSubscription | Public method to load a subscription required by another one.
page | Public method to get a reference to the page block object.
removeException | Public method to remove an exception.
removeSubscription | Public method to remove an AdBlock subscription.
save | Public method to save the AdBlock subscriptions.
setEnabled | Public slot to set the enabled state.
setExceptions | Public method to set the list of excepted hosts.
setUseLimitedEasyList | Public method to set the limited EasyList flag.
showDialog | Public slot to show the AdBlock subscription management dialog.
showExceptionsDialog | Public method to show the AdBlock Exceptions dialog.
subscription | Public method to get a subscription based on its location.
subscriptions | Public method to get all subscriptions.
updateAllSubscriptions | Public method to update all subscriptions.
useLimitedEasyList | Public method to test, if limited EasyList rules shall be used.

### Static Methods

None

#### AdBlockManager (Constructor)

AdBlockManager(parent=None)

Constructor

parent (QObject)
  reference to the parent object

#### AdBlockManager.__canBeBlocked

__canBeBlocked(url)

Private method to check, if the given URL could be blocked (i.e. is not whitelisted).

url (QUrl)
  URL to be checked

Returns:
  flag indicating that the given URL can be blocked

Return Type:
  bool

#### AdBlockManager.__customSubscriptionLocation

__customSubscriptionLocation()

Private method to generate the path for custom subscriptions.

Returns:
  URL for custom subscriptions

Return Type:
  QUrl

#### AdBlockManager.__customSubscriptionUrl

__customSubscriptionUrl()

Private method to generate the URL for custom subscriptions.

Returns:
  URL for custom subscriptions

Return Type:
  QUrl

#### AdBlockManager.__loadSubscriptions

__loadSubscriptions()

Private method to load the set of subscriptions.

#### AdBlockManager.__rulesChanged

__rulesChanged()

Private slot handling a change of the AdBlock rules.

#### AdBlockManager.__updateMatcher

__updateMatcher()

Private slot to update the adblock matcher.

#### AdBlockManager.addException

addException(host)

Public method to add an exception.

host (str)
  to be excepted

#### AdBlockManager.addSubscription

addSubscription(subscription)

Public method to add an AdBlock subscription.

subscription (AdBlockSubscription)
  AdBlock subscription to be added

#### AdBlockManager.addSubscriptionFromUrl

addSubscriptionFromUrl(url)

Public method to ad an AdBlock subscription given the abp URL.

url (QUrl)
  URL to subscribe an AdBlock subscription

Returns:
  flag indicating success

Return Type:
  bool

#### AdBlockManager.block

block(info)

Public method to check, if a request should be blocked.

info (QWebEngineUrlRequestInfo)
  request info object

Returns:
  flag indicating to block the request

Return Type:
  bool

#### AdBlockManager.canRunOnScheme

canRunOnScheme(scheme)

Public method to check, if AdBlock can be performed on the scheme.

scheme (str)
  scheme to check

Returns:
  flag indicating, that AdBlock can be performed

Return Type:
  bool

#### AdBlockManager.close

close()

Public method to close the open search engines manager.

#### AdBlockManager.customRules

customRules()

Public method to get a subscription for custom rules.

Returns:
  subscription object for custom rules

Return Type:
  AdBlockSubscription

#### AdBlockManager.elementHidingRules

elementHidingRules(url)

Public method to get the element hiding rules.

url (QUrl)
  URL to get hiding rules for

Returns:
  element hiding rules

Return Type:
  str

#### AdBlockManager.elementHidingRulesForDomain

elementHidingRulesForDomain(url)

Public method to get the element hiding rules for a domain.

url (QUrl)
  URL to get hiding rules for

Returns:
  element hiding rules

Return Type:
  str

#### AdBlockManager.exceptions

exceptions()

Public method to get a list of excepted hosts.

Returns:
  list of excepted hosts

Return Type:
  list of str

#### AdBlockManager.getDefaultSubscriptionUrl

getDefaultSubscriptionUrl()

Public method to get the default subscription URL.

Returns:
  default subscription URL

Return Type:
  str

#### AdBlockManager.getRequiresSubscriptions

getRequiresSubscriptions(subscription)

Public method to get a list of subscriptions, that require the given one.

subscription (AdBlockSubscription)
  subscription to check for

Returns:
  list of subscription requiring the given one

Return Type:
  list of AdBlockSubscription

#### AdBlockManager.isEnabled

isEnabled()

Public method to check, if blocking ads is enabled.

Returns:
  flag indicating the enabled state

Return Type:
  bool

#### AdBlockManager.isHostExcepted

isHostExcepted(host)

Public slot to check, if a host is excepted.

host (str)
  host to check

Returns:
  flag indicating an exception

Return Type:
  bool

#### AdBlockManager.load

load()

Public method to load the AdBlock subscriptions.

#### AdBlockManager.loadRequiredSubscription

loadRequiredSubscription(location, title)

Public method to load a subscription required by another one.

location (str)
  location of the required subscription
title (str)
  title of the required subscription

#### AdBlockManager.page

page()

Public method to get a reference to the page block object.

Returns:
  reference to the page block object

Return Type:
  AdBlockPage

#### AdBlockManager.removeException

removeException(host)

Public method to remove an exception.

host (str)
  to be removed from the list of exceptions

#### AdBlockManager.removeSubscription

removeSubscription(subscription, emitSignal=True)

Public method to remove an AdBlock subscription.

subscription (AdBlockSubscription)
  AdBlock subscription to be removed
emitSignal (bool)
  flag indicating to send a signal

#### AdBlockManager.save

save()

Public method to save the AdBlock subscriptions.

#### AdBlockManager.setEnabled

setEnabled(enabled)

Public slot to set the enabled state.

enabled (bool)
  flag indicating the enabled state

#### AdBlockManager.setExceptions

setExceptions(hosts)

Public method to set the list of excepted hosts.

hosts (list of str)
  list of excepted hosts

#### AdBlockManager.setUseLimitedEasyList

setUseLimitedEasyList(limited)

Public method to set the limited EasyList flag.

limited (bool)
  flag indicating to use limited EasyList

#### AdBlockManager.showDialog

showDialog()

Public slot to show the AdBlock subscription management dialog.

Returns:
  reference to the dialog

Return Type:
  AdBlockDialog

#### AdBlockManager.showExceptionsDialog

showExceptionsDialog()

Public method to show the AdBlock Exceptions dialog.

Returns:
  reference to the exceptions dialog

Return Type:
  AdBlockExceptionsDialog

#### AdBlockManager.subscription

subscription(location)

Public method to get a subscription based on its location.

location (str)
  location of the subscription to search for

Returns:
  subscription or None

Return Type:
  AdBlockSubscription

#### AdBlockManager.subscriptions

subscriptions()

Public method to get all subscriptions.

Returns:
  list of subscriptions

Return Type:
  list of AdBlockSubscription

#### AdBlockManager.updateAllSubscriptions

updateAllSubscriptions()

Public method to update all subscriptions.

#### AdBlockManager.useLimitedEasyList

useLimitedEasyList()

Public method to test, if limited EasyList rules shall be used.

Returns:
  flag indicating limited EasyList rules

Return Type:
  bool

Up