Sat, 28 Jul 2012 11:23:12 +0200
Reworked some of the AdBlock code to achieve some speed improvements.
--- a/APIs/Python3/eric5.api Thu Jul 26 18:38:15 2012 +0200 +++ b/APIs/Python3/eric5.api Sat Jul 28 11:23:12 2012 +0200 @@ -1684,7 +1684,7 @@ eric5.Helpviewer.AdBlock.AdBlockAccessHandler.AdBlockAccessHandler.createRequest?4(op, request, outgoingData=None) eric5.Helpviewer.AdBlock.AdBlockBlockedNetworkReply.AdBlockBlockedNetworkReply.abort?4() eric5.Helpviewer.AdBlock.AdBlockBlockedNetworkReply.AdBlockBlockedNetworkReply.readData?4(maxlen) -eric5.Helpviewer.AdBlock.AdBlockBlockedNetworkReply.AdBlockBlockedNetworkReply?1(request, rule, parent=None) +eric5.Helpviewer.AdBlock.AdBlockBlockedNetworkReply.AdBlockBlockedNetworkReply?1(request, subscription, rule, parent=None) eric5.Helpviewer.AdBlock.AdBlockDialog.AdBlockDialog.addCustomRule?4(rule="") eric5.Helpviewer.AdBlock.AdBlockDialog.AdBlockDialog.model?4() eric5.Helpviewer.AdBlock.AdBlockDialog.AdBlockDialog.on_updateSpinBox_valueChanged?4(value) @@ -1693,6 +1693,8 @@ eric5.Helpviewer.AdBlock.AdBlockManager.AdBlockManager.addSubscription?4(subscription) eric5.Helpviewer.AdBlock.AdBlockManager.AdBlockManager.close?4() eric5.Helpviewer.AdBlock.AdBlockManager.AdBlockManager.customRules?4() +eric5.Helpviewer.AdBlock.AdBlockManager.AdBlockManager.elementHidingRules?4() +eric5.Helpviewer.AdBlock.AdBlockManager.AdBlockManager.elementHidingRulesForDomain?4(url) eric5.Helpviewer.AdBlock.AdBlockManager.AdBlockManager.isEnabled?4() eric5.Helpviewer.AdBlock.AdBlockManager.AdBlockManager.load?4() eric5.Helpviewer.AdBlock.AdBlockManager.AdBlockManager.network?4() @@ -1719,28 +1721,45 @@ eric5.Helpviewer.AdBlock.AdBlockModel.AdBlockModel.subscriptionIndex?4(subscription) eric5.Helpviewer.AdBlock.AdBlockModel.AdBlockModel?1(parent=None) eric5.Helpviewer.AdBlock.AdBlockNetwork.AdBlockNetwork.block?4(request) -eric5.Helpviewer.AdBlock.AdBlockPage.AdBlockPage.applyRulesToPage?4(page) +eric5.Helpviewer.AdBlock.AdBlockNetwork.AdBlockNetwork.canRunOnScheme?4(scheme) +eric5.Helpviewer.AdBlock.AdBlockPage.AdBlockPage.hideBlockedPageEntries?4(page) +eric5.Helpviewer.AdBlock.AdBlockPage.AdBlockedPageEntry.urlString?4() +eric5.Helpviewer.AdBlock.AdBlockPage.AdBlockedPageEntry?1(rule, url) +eric5.Helpviewer.AdBlock.AdBlockRule.AdBlockRule.cssSelector?4() eric5.Helpviewer.AdBlock.AdBlockRule.AdBlockRule.filter?4() eric5.Helpviewer.AdBlock.AdBlockRule.AdBlockRule.isCSSRule?4() +eric5.Helpviewer.AdBlock.AdBlockRule.AdBlockRule.isComment?4() +eric5.Helpviewer.AdBlock.AdBlockRule.AdBlockRule.isDocument?4() +eric5.Helpviewer.AdBlock.AdBlockRule.AdBlockRule.isDomainRestricted?4() +eric5.Helpviewer.AdBlock.AdBlockRule.AdBlockRule.isElementHiding?4() eric5.Helpviewer.AdBlock.AdBlockRule.AdBlockRule.isEnabled?4() eric5.Helpviewer.AdBlock.AdBlockRule.AdBlockRule.isException?4() -eric5.Helpviewer.AdBlock.AdBlockRule.AdBlockRule.networkMatch?4(encodedUrl) -eric5.Helpviewer.AdBlock.AdBlockRule.AdBlockRule.regExpPattern?4() +eric5.Helpviewer.AdBlock.AdBlockRule.AdBlockRule.isInternalDisabled?4() +eric5.Helpviewer.AdBlock.AdBlockRule.AdBlockRule.isSlow?4() +eric5.Helpviewer.AdBlock.AdBlockRule.AdBlockRule.matchDomain?4(domain) +eric5.Helpviewer.AdBlock.AdBlockRule.AdBlockRule.matchObject?4(req) +eric5.Helpviewer.AdBlock.AdBlockRule.AdBlockRule.matchSubdocument?4(req) +eric5.Helpviewer.AdBlock.AdBlockRule.AdBlockRule.matchThirdParty?4(req) +eric5.Helpviewer.AdBlock.AdBlockRule.AdBlockRule.matchXmlHttpRequest?4(req) +eric5.Helpviewer.AdBlock.AdBlockRule.AdBlockRule.networkMatch?4(request, domain, encodedUrl) eric5.Helpviewer.AdBlock.AdBlockRule.AdBlockRule.setEnabled?4(enabled) eric5.Helpviewer.AdBlock.AdBlockRule.AdBlockRule.setException?4(exception) eric5.Helpviewer.AdBlock.AdBlockRule.AdBlockRule.setFilter?4(filter) -eric5.Helpviewer.AdBlock.AdBlockRule.AdBlockRule.setPattern?4(pattern, isRegExp) +eric5.Helpviewer.AdBlock.AdBlockRule.AdBlockRule.urlMatch?4(url) eric5.Helpviewer.AdBlock.AdBlockRule.AdBlockRule?1(filter="") +eric5.Helpviewer.AdBlock.AdBlockRule.toSecondLevelDomain?4(url) +eric5.Helpviewer.AdBlock.AdBlockSubscription.AdBlockSubscription.adBlockDisabledForUrl?4(url) eric5.Helpviewer.AdBlock.AdBlockSubscription.AdBlockSubscription.addRule?4(rule) eric5.Helpviewer.AdBlock.AdBlockSubscription.AdBlockSubscription.allRules?4() -eric5.Helpviewer.AdBlock.AdBlockSubscription.AdBlockSubscription.allow?4(urlString) -eric5.Helpviewer.AdBlock.AdBlockSubscription.AdBlockSubscription.block?4(urlString) eric5.Helpviewer.AdBlock.AdBlockSubscription.AdBlockSubscription.changed?7 eric5.Helpviewer.AdBlock.AdBlockSubscription.AdBlockSubscription.checkForUpdate?4() +eric5.Helpviewer.AdBlock.AdBlockSubscription.AdBlockSubscription.elemHideDisabledForUrl?4(url) +eric5.Helpviewer.AdBlock.AdBlockSubscription.AdBlockSubscription.elementHidingRules?4() +eric5.Helpviewer.AdBlock.AdBlockSubscription.AdBlockSubscription.elementHidingRulesForDomain?4(domain) eric5.Helpviewer.AdBlock.AdBlockSubscription.AdBlockSubscription.isEnabled?4() eric5.Helpviewer.AdBlock.AdBlockSubscription.AdBlockSubscription.lastUpdate?4() eric5.Helpviewer.AdBlock.AdBlockSubscription.AdBlockSubscription.location?4() -eric5.Helpviewer.AdBlock.AdBlockSubscription.AdBlockSubscription.pageRules?4() +eric5.Helpviewer.AdBlock.AdBlockSubscription.AdBlockSubscription.match?4(req, urlDomain, urlString) eric5.Helpviewer.AdBlock.AdBlockSubscription.AdBlockSubscription.removeRule?4(offset) eric5.Helpviewer.AdBlock.AdBlockSubscription.AdBlockSubscription.replaceRule?4(rule, offset) eric5.Helpviewer.AdBlock.AdBlockSubscription.AdBlockSubscription.rulesChanged?7 @@ -2194,8 +2213,10 @@ eric5.Helpviewer.HelpBrowserWV.HelpBrowser?1(mainWindow, parent=None, name="") eric5.Helpviewer.HelpBrowserWV.HelpWebPage._webPluginFactory?8 eric5.Helpviewer.HelpBrowserWV.HelpWebPage.acceptNavigationRequest?4(frame, request, type_) +eric5.Helpviewer.HelpBrowserWV.HelpWebPage.addAdBlockRule?4(rule, url) eric5.Helpviewer.HelpBrowserWV.HelpWebPage.event?4(evt) eric5.Helpviewer.HelpBrowserWV.HelpWebPage.extension?4(extension, option, output) +eric5.Helpviewer.HelpBrowserWV.HelpWebPage.getAdBlockedPageEntries?4() eric5.Helpviewer.HelpBrowserWV.HelpWebPage.getSslInfo?4() eric5.Helpviewer.HelpBrowserWV.HelpWebPage.hasValidSslInfo?4() eric5.Helpviewer.HelpBrowserWV.HelpWebPage.pageAttributeId?4() @@ -2203,6 +2224,7 @@ eric5.Helpviewer.HelpBrowserWV.HelpWebPage.setUserAgent?4(agent) eric5.Helpviewer.HelpBrowserWV.HelpWebPage.showSslInfo?4() eric5.Helpviewer.HelpBrowserWV.HelpWebPage.supportsExtension?4(extension) +eric5.Helpviewer.HelpBrowserWV.HelpWebPage.url?4() eric5.Helpviewer.HelpBrowserWV.HelpWebPage.userAgent?4(resolveEmpty=False) eric5.Helpviewer.HelpBrowserWV.HelpWebPage.userAgentForUrl?4(url) eric5.Helpviewer.HelpBrowserWV.HelpWebPage.webPluginFactory?4()
--- a/Documentation/Help/source.qhp Thu Jul 26 18:38:15 2012 +0200 +++ b/Documentation/Help/source.qhp Sat Jul 28 11:23:12 2012 +0200 @@ -1070,6 +1070,8 @@ <keyword name="AdBlockManager.addSubscription" id="AdBlockManager.addSubscription" ref="eric5.Helpviewer.AdBlock.AdBlockManager.html#AdBlockManager.addSubscription" /> <keyword name="AdBlockManager.close" id="AdBlockManager.close" ref="eric5.Helpviewer.AdBlock.AdBlockManager.html#AdBlockManager.close" /> <keyword name="AdBlockManager.customRules" id="AdBlockManager.customRules" ref="eric5.Helpviewer.AdBlock.AdBlockManager.html#AdBlockManager.customRules" /> + <keyword name="AdBlockManager.elementHidingRules" id="AdBlockManager.elementHidingRules" ref="eric5.Helpviewer.AdBlock.AdBlockManager.html#AdBlockManager.elementHidingRules" /> + <keyword name="AdBlockManager.elementHidingRulesForDomain" id="AdBlockManager.elementHidingRulesForDomain" ref="eric5.Helpviewer.AdBlock.AdBlockManager.html#AdBlockManager.elementHidingRulesForDomain" /> <keyword name="AdBlockManager.isEnabled" id="AdBlockManager.isEnabled" ref="eric5.Helpviewer.AdBlock.AdBlockManager.html#AdBlockManager.isEnabled" /> <keyword name="AdBlockManager.load" id="AdBlockManager.load" ref="eric5.Helpviewer.AdBlock.AdBlockManager.html#AdBlockManager.load" /> <keyword name="AdBlockManager.network" id="AdBlockManager.network" ref="eric5.Helpviewer.AdBlock.AdBlockManager.html#AdBlockManager.network" /> @@ -1098,25 +1100,39 @@ <keyword name="AdBlockModel.subscriptionIndex" id="AdBlockModel.subscriptionIndex" ref="eric5.Helpviewer.AdBlock.AdBlockModel.html#AdBlockModel.subscriptionIndex" /> <keyword name="AdBlockNetwork" id="AdBlockNetwork" ref="eric5.Helpviewer.AdBlock.AdBlockNetwork.html#AdBlockNetwork" /> <keyword name="AdBlockNetwork (Module)" id="AdBlockNetwork (Module)" ref="eric5.Helpviewer.AdBlock.AdBlockNetwork.html" /> + <keyword name="AdBlockNetwork.__canBeBlocked" id="AdBlockNetwork.__canBeBlocked" ref="eric5.Helpviewer.AdBlock.AdBlockNetwork.html#AdBlockNetwork.__canBeBlocked" /> <keyword name="AdBlockNetwork.block" id="AdBlockNetwork.block" ref="eric5.Helpviewer.AdBlock.AdBlockNetwork.html#AdBlockNetwork.block" /> + <keyword name="AdBlockNetwork.canRunOnScheme" id="AdBlockNetwork.canRunOnScheme" ref="eric5.Helpviewer.AdBlock.AdBlockNetwork.html#AdBlockNetwork.canRunOnScheme" /> <keyword name="AdBlockPage" id="AdBlockPage" ref="eric5.Helpviewer.AdBlock.AdBlockPage.html#AdBlockPage" /> <keyword name="AdBlockPage (Module)" id="AdBlockPage (Module)" ref="eric5.Helpviewer.AdBlock.AdBlockPage.html" /> - <keyword name="AdBlockPage.__checkRule" id="AdBlockPage.__checkRule" ref="eric5.Helpviewer.AdBlock.AdBlockPage.html#AdBlockPage.__checkRule" /> - <keyword name="AdBlockPage.applyRulesToPage" id="AdBlockPage.applyRulesToPage" ref="eric5.Helpviewer.AdBlock.AdBlockPage.html#AdBlockPage.applyRulesToPage" /> + <keyword name="AdBlockPage.hideBlockedPageEntries" id="AdBlockPage.hideBlockedPageEntries" ref="eric5.Helpviewer.AdBlock.AdBlockPage.html#AdBlockPage.hideBlockedPageEntries" /> <keyword name="AdBlockRule" id="AdBlockRule" ref="eric5.Helpviewer.AdBlock.AdBlockRule.html#AdBlockRule" /> <keyword name="AdBlockRule (Constructor)" id="AdBlockRule (Constructor)" ref="eric5.Helpviewer.AdBlock.AdBlockRule.html#AdBlockRule.__init__" /> <keyword name="AdBlockRule (Module)" id="AdBlockRule (Module)" ref="eric5.Helpviewer.AdBlock.AdBlockRule.html" /> <keyword name="AdBlockRule.__convertPatternToRegExp" id="AdBlockRule.__convertPatternToRegExp" ref="eric5.Helpviewer.AdBlock.AdBlockRule.html#AdBlockRule.__convertPatternToRegExp" /> + <keyword name="AdBlockRule.__parseDomains" id="AdBlockRule.__parseDomains" ref="eric5.Helpviewer.AdBlock.AdBlockRule.html#AdBlockRule.__parseDomains" /> + <keyword name="AdBlockRule.__parseFilter" id="AdBlockRule.__parseFilter" ref="eric5.Helpviewer.AdBlock.AdBlockRule.html#AdBlockRule.__parseFilter" /> + <keyword name="AdBlockRule.cssSelector" id="AdBlockRule.cssSelector" ref="eric5.Helpviewer.AdBlock.AdBlockRule.html#AdBlockRule.cssSelector" /> <keyword name="AdBlockRule.filter" id="AdBlockRule.filter" ref="eric5.Helpviewer.AdBlock.AdBlockRule.html#AdBlockRule.filter" /> <keyword name="AdBlockRule.isCSSRule" id="AdBlockRule.isCSSRule" ref="eric5.Helpviewer.AdBlock.AdBlockRule.html#AdBlockRule.isCSSRule" /> + <keyword name="AdBlockRule.isComment" id="AdBlockRule.isComment" ref="eric5.Helpviewer.AdBlock.AdBlockRule.html#AdBlockRule.isComment" /> + <keyword name="AdBlockRule.isDocument" id="AdBlockRule.isDocument" ref="eric5.Helpviewer.AdBlock.AdBlockRule.html#AdBlockRule.isDocument" /> + <keyword name="AdBlockRule.isDomainRestricted" id="AdBlockRule.isDomainRestricted" ref="eric5.Helpviewer.AdBlock.AdBlockRule.html#AdBlockRule.isDomainRestricted" /> + <keyword name="AdBlockRule.isElementHiding" id="AdBlockRule.isElementHiding" ref="eric5.Helpviewer.AdBlock.AdBlockRule.html#AdBlockRule.isElementHiding" /> <keyword name="AdBlockRule.isEnabled" id="AdBlockRule.isEnabled" ref="eric5.Helpviewer.AdBlock.AdBlockRule.html#AdBlockRule.isEnabled" /> <keyword name="AdBlockRule.isException" id="AdBlockRule.isException" ref="eric5.Helpviewer.AdBlock.AdBlockRule.html#AdBlockRule.isException" /> + <keyword name="AdBlockRule.isInternalDisabled" id="AdBlockRule.isInternalDisabled" ref="eric5.Helpviewer.AdBlock.AdBlockRule.html#AdBlockRule.isInternalDisabled" /> + <keyword name="AdBlockRule.isSlow" id="AdBlockRule.isSlow" ref="eric5.Helpviewer.AdBlock.AdBlockRule.html#AdBlockRule.isSlow" /> + <keyword name="AdBlockRule.matchDomain" id="AdBlockRule.matchDomain" ref="eric5.Helpviewer.AdBlock.AdBlockRule.html#AdBlockRule.matchDomain" /> + <keyword name="AdBlockRule.matchObject" id="AdBlockRule.matchObject" ref="eric5.Helpviewer.AdBlock.AdBlockRule.html#AdBlockRule.matchObject" /> + <keyword name="AdBlockRule.matchSubdocument" id="AdBlockRule.matchSubdocument" ref="eric5.Helpviewer.AdBlock.AdBlockRule.html#AdBlockRule.matchSubdocument" /> + <keyword name="AdBlockRule.matchThirdParty" id="AdBlockRule.matchThirdParty" ref="eric5.Helpviewer.AdBlock.AdBlockRule.html#AdBlockRule.matchThirdParty" /> + <keyword name="AdBlockRule.matchXmlHttpRequest" id="AdBlockRule.matchXmlHttpRequest" ref="eric5.Helpviewer.AdBlock.AdBlockRule.html#AdBlockRule.matchXmlHttpRequest" /> <keyword name="AdBlockRule.networkMatch" id="AdBlockRule.networkMatch" ref="eric5.Helpviewer.AdBlock.AdBlockRule.html#AdBlockRule.networkMatch" /> - <keyword name="AdBlockRule.regExpPattern" id="AdBlockRule.regExpPattern" ref="eric5.Helpviewer.AdBlock.AdBlockRule.html#AdBlockRule.regExpPattern" /> <keyword name="AdBlockRule.setEnabled" id="AdBlockRule.setEnabled" ref="eric5.Helpviewer.AdBlock.AdBlockRule.html#AdBlockRule.setEnabled" /> <keyword name="AdBlockRule.setException" id="AdBlockRule.setException" ref="eric5.Helpviewer.AdBlock.AdBlockRule.html#AdBlockRule.setException" /> <keyword name="AdBlockRule.setFilter" id="AdBlockRule.setFilter" ref="eric5.Helpviewer.AdBlock.AdBlockRule.html#AdBlockRule.setFilter" /> - <keyword name="AdBlockRule.setPattern" id="AdBlockRule.setPattern" ref="eric5.Helpviewer.AdBlock.AdBlockRule.html#AdBlockRule.setPattern" /> + <keyword name="AdBlockRule.urlMatch" id="AdBlockRule.urlMatch" ref="eric5.Helpviewer.AdBlock.AdBlockRule.html#AdBlockRule.urlMatch" /> <keyword name="AdBlockSubscription" id="AdBlockSubscription" ref="eric5.Helpviewer.AdBlock.AdBlockSubscription.html#AdBlockSubscription" /> <keyword name="AdBlockSubscription (Constructor)" id="AdBlockSubscription (Constructor)" ref="eric5.Helpviewer.AdBlock.AdBlockSubscription.html#AdBlockSubscription.__init__" /> <keyword name="AdBlockSubscription (Module)" id="AdBlockSubscription (Module)" ref="eric5.Helpviewer.AdBlock.AdBlockSubscription.html" /> @@ -1124,15 +1140,17 @@ <keyword name="AdBlockSubscription.__parseUrl" id="AdBlockSubscription.__parseUrl" ref="eric5.Helpviewer.AdBlock.AdBlockSubscription.html#AdBlockSubscription.__parseUrl" /> <keyword name="AdBlockSubscription.__populateCache" id="AdBlockSubscription.__populateCache" ref="eric5.Helpviewer.AdBlock.AdBlockSubscription.html#AdBlockSubscription.__populateCache" /> <keyword name="AdBlockSubscription.__rulesDownloaded" id="AdBlockSubscription.__rulesDownloaded" ref="eric5.Helpviewer.AdBlock.AdBlockSubscription.html#AdBlockSubscription.__rulesDownloaded" /> + <keyword name="AdBlockSubscription.adBlockDisabledForUrl" id="AdBlockSubscription.adBlockDisabledForUrl" ref="eric5.Helpviewer.AdBlock.AdBlockSubscription.html#AdBlockSubscription.adBlockDisabledForUrl" /> <keyword name="AdBlockSubscription.addRule" id="AdBlockSubscription.addRule" ref="eric5.Helpviewer.AdBlock.AdBlockSubscription.html#AdBlockSubscription.addRule" /> <keyword name="AdBlockSubscription.allRules" id="AdBlockSubscription.allRules" ref="eric5.Helpviewer.AdBlock.AdBlockSubscription.html#AdBlockSubscription.allRules" /> - <keyword name="AdBlockSubscription.allow" id="AdBlockSubscription.allow" ref="eric5.Helpviewer.AdBlock.AdBlockSubscription.html#AdBlockSubscription.allow" /> - <keyword name="AdBlockSubscription.block" id="AdBlockSubscription.block" ref="eric5.Helpviewer.AdBlock.AdBlockSubscription.html#AdBlockSubscription.block" /> <keyword name="AdBlockSubscription.checkForUpdate" id="AdBlockSubscription.checkForUpdate" ref="eric5.Helpviewer.AdBlock.AdBlockSubscription.html#AdBlockSubscription.checkForUpdate" /> + <keyword name="AdBlockSubscription.elemHideDisabledForUrl" id="AdBlockSubscription.elemHideDisabledForUrl" ref="eric5.Helpviewer.AdBlock.AdBlockSubscription.html#AdBlockSubscription.elemHideDisabledForUrl" /> + <keyword name="AdBlockSubscription.elementHidingRules" id="AdBlockSubscription.elementHidingRules" ref="eric5.Helpviewer.AdBlock.AdBlockSubscription.html#AdBlockSubscription.elementHidingRules" /> + <keyword name="AdBlockSubscription.elementHidingRulesForDomain" id="AdBlockSubscription.elementHidingRulesForDomain" ref="eric5.Helpviewer.AdBlock.AdBlockSubscription.html#AdBlockSubscription.elementHidingRulesForDomain" /> <keyword name="AdBlockSubscription.isEnabled" id="AdBlockSubscription.isEnabled" ref="eric5.Helpviewer.AdBlock.AdBlockSubscription.html#AdBlockSubscription.isEnabled" /> <keyword name="AdBlockSubscription.lastUpdate" id="AdBlockSubscription.lastUpdate" ref="eric5.Helpviewer.AdBlock.AdBlockSubscription.html#AdBlockSubscription.lastUpdate" /> <keyword name="AdBlockSubscription.location" id="AdBlockSubscription.location" ref="eric5.Helpviewer.AdBlock.AdBlockSubscription.html#AdBlockSubscription.location" /> - <keyword name="AdBlockSubscription.pageRules" id="AdBlockSubscription.pageRules" ref="eric5.Helpviewer.AdBlock.AdBlockSubscription.html#AdBlockSubscription.pageRules" /> + <keyword name="AdBlockSubscription.match" id="AdBlockSubscription.match" ref="eric5.Helpviewer.AdBlock.AdBlockSubscription.html#AdBlockSubscription.match" /> <keyword name="AdBlockSubscription.removeRule" id="AdBlockSubscription.removeRule" ref="eric5.Helpviewer.AdBlock.AdBlockSubscription.html#AdBlockSubscription.removeRule" /> <keyword name="AdBlockSubscription.replaceRule" id="AdBlockSubscription.replaceRule" ref="eric5.Helpviewer.AdBlock.AdBlockSubscription.html#AdBlockSubscription.replaceRule" /> <keyword name="AdBlockSubscription.rulesFileName" id="AdBlockSubscription.rulesFileName" ref="eric5.Helpviewer.AdBlock.AdBlockSubscription.html#AdBlockSubscription.rulesFileName" /> @@ -1143,6 +1161,10 @@ <keyword name="AdBlockSubscription.title" id="AdBlockSubscription.title" ref="eric5.Helpviewer.AdBlock.AdBlockSubscription.html#AdBlockSubscription.title" /> <keyword name="AdBlockSubscription.updateNow" id="AdBlockSubscription.updateNow" ref="eric5.Helpviewer.AdBlock.AdBlockSubscription.html#AdBlockSubscription.updateNow" /> <keyword name="AdBlockSubscription.url" id="AdBlockSubscription.url" ref="eric5.Helpviewer.AdBlock.AdBlockSubscription.html#AdBlockSubscription.url" /> + <keyword name="AdBlockedPageEntry" id="AdBlockedPageEntry" ref="eric5.Helpviewer.AdBlock.AdBlockPage.html#AdBlockedPageEntry" /> + <keyword name="AdBlockedPageEntry (Constructor)" id="AdBlockedPageEntry (Constructor)" ref="eric5.Helpviewer.AdBlock.AdBlockPage.html#AdBlockedPageEntry.__init__" /> + <keyword name="AdBlockedPageEntry.__eq__" id="AdBlockedPageEntry.__eq__" ref="eric5.Helpviewer.AdBlock.AdBlockPage.html#AdBlockedPageEntry.__eq__" /> + <keyword name="AdBlockedPageEntry.urlString" id="AdBlockedPageEntry.urlString" ref="eric5.Helpviewer.AdBlock.AdBlockPage.html#AdBlockedPageEntry.urlString" /> <keyword name="AddBookmarkDialog" id="AddBookmarkDialog" ref="eric5.Helpviewer.Bookmarks.AddBookmarkDialog.html#AddBookmarkDialog" /> <keyword name="AddBookmarkDialog (Constructor)" id="AddBookmarkDialog (Constructor)" ref="eric5.Helpviewer.Bookmarks.AddBookmarkDialog.html#AddBookmarkDialog.__init__" /> <keyword name="AddBookmarkDialog (Module)" id="AddBookmarkDialog (Module)" ref="eric5.Helpviewer.Bookmarks.AddBookmarkDialog.html" /> @@ -4818,10 +4840,13 @@ <keyword name="HelpWebBrowserPage.save" id="HelpWebBrowserPage.save" ref="eric5.Preferences.ConfigurationPages.HelpWebBrowserPage.html#HelpWebBrowserPage.save" /> <keyword name="HelpWebPage" id="HelpWebPage" ref="eric5.Helpviewer.HelpBrowserWV.html#HelpWebPage" /> <keyword name="HelpWebPage (Constructor)" id="HelpWebPage (Constructor)" ref="eric5.Helpviewer.HelpBrowserWV.html#HelpWebPage.__init__" /> + <keyword name="HelpWebPage.__loadStarted" id="HelpWebPage.__loadStarted" ref="eric5.Helpviewer.HelpBrowserWV.html#HelpWebPage.__loadStarted" /> <keyword name="HelpWebPage.__managerFinished" id="HelpWebPage.__managerFinished" ref="eric5.Helpviewer.HelpBrowserWV.html#HelpWebPage.__managerFinished" /> <keyword name="HelpWebPage.acceptNavigationRequest" id="HelpWebPage.acceptNavigationRequest" ref="eric5.Helpviewer.HelpBrowserWV.html#HelpWebPage.acceptNavigationRequest" /> + <keyword name="HelpWebPage.addAdBlockRule" id="HelpWebPage.addAdBlockRule" ref="eric5.Helpviewer.HelpBrowserWV.html#HelpWebPage.addAdBlockRule" /> <keyword name="HelpWebPage.event" id="HelpWebPage.event" ref="eric5.Helpviewer.HelpBrowserWV.html#HelpWebPage.event" /> <keyword name="HelpWebPage.extension" id="HelpWebPage.extension" ref="eric5.Helpviewer.HelpBrowserWV.html#HelpWebPage.extension" /> + <keyword name="HelpWebPage.getAdBlockedPageEntries" id="HelpWebPage.getAdBlockedPageEntries" ref="eric5.Helpviewer.HelpBrowserWV.html#HelpWebPage.getAdBlockedPageEntries" /> <keyword name="HelpWebPage.getSslInfo" id="HelpWebPage.getSslInfo" ref="eric5.Helpviewer.HelpBrowserWV.html#HelpWebPage.getSslInfo" /> <keyword name="HelpWebPage.hasValidSslInfo" id="HelpWebPage.hasValidSslInfo" ref="eric5.Helpviewer.HelpBrowserWV.html#HelpWebPage.hasValidSslInfo" /> <keyword name="HelpWebPage.pageAttributeId" id="HelpWebPage.pageAttributeId" ref="eric5.Helpviewer.HelpBrowserWV.html#HelpWebPage.pageAttributeId" /> @@ -4829,6 +4854,7 @@ <keyword name="HelpWebPage.setUserAgent" id="HelpWebPage.setUserAgent" ref="eric5.Helpviewer.HelpBrowserWV.html#HelpWebPage.setUserAgent" /> <keyword name="HelpWebPage.showSslInfo" id="HelpWebPage.showSslInfo" ref="eric5.Helpviewer.HelpBrowserWV.html#HelpWebPage.showSslInfo" /> <keyword name="HelpWebPage.supportsExtension" id="HelpWebPage.supportsExtension" ref="eric5.Helpviewer.HelpBrowserWV.html#HelpWebPage.supportsExtension" /> + <keyword name="HelpWebPage.url" id="HelpWebPage.url" ref="eric5.Helpviewer.HelpBrowserWV.html#HelpWebPage.url" /> <keyword name="HelpWebPage.userAgent" id="HelpWebPage.userAgent" ref="eric5.Helpviewer.HelpBrowserWV.html#HelpWebPage.userAgent" /> <keyword name="HelpWebPage.userAgentForUrl" id="HelpWebPage.userAgentForUrl" ref="eric5.Helpviewer.HelpBrowserWV.html#HelpWebPage.userAgentForUrl" /> <keyword name="HelpWebPage.webPluginFactory" id="HelpWebPage.webPluginFactory" ref="eric5.Helpviewer.HelpBrowserWV.html#HelpWebPage.webPluginFactory" /> @@ -12158,6 +12184,7 @@ <keyword name="toDict" id="toDict" ref="eric5.Preferences.__init__.html#toDict" /> <keyword name="toList" id="toList" ref="eric5.Preferences.__init__.html#toList" /> <keyword name="toNativeSeparators" id="toNativeSeparators" ref="eric5.Utilities.__init__.html#toNativeSeparators" /> + <keyword name="toSecondLevelDomain" id="toSecondLevelDomain" ref="eric5.Helpviewer.AdBlock.AdBlockRule.html#toSecondLevelDomain" /> <keyword name="traceRuby?" id="traceRuby?" ref="eric5.DebugClients.Ruby.Debuggee.html#traceRuby?" /> <keyword name="trailing_blank_lines" id="trailing_blank_lines" ref="eric5.Plugins.CheckerPlugins.Pep8.pep8.html#trailing_blank_lines" /> <keyword name="trailing_blank_lines" id="trailing_blank_lines" ref="eric5.UtilitiesPython2.pep8.html#trailing_blank_lines" />
--- a/Documentation/Source/eric5.Helpviewer.AdBlock.AdBlockBlockedNetworkReply.html Thu Jul 26 18:38:15 2012 +0200 +++ b/Documentation/Source/eric5.Helpviewer.AdBlock.AdBlockBlockedNetworkReply.html Sat Jul 28 11:23:12 2012 +0200 @@ -77,19 +77,22 @@ </table> <a NAME="AdBlockBlockedNetworkReply.__init__" ID="AdBlockBlockedNetworkReply.__init__"></a> <h4>AdBlockBlockedNetworkReply (Constructor)</h4> -<b>AdBlockBlockedNetworkReply</b>(<i>request, rule, parent=None</i>) +<b>AdBlockBlockedNetworkReply</b>(<i>request, subscription, rule, parent=None</i>) <p> Constructor </p><dl> <dt><i>request</i></dt> <dd> reference to the request object (QNetworkRequest) -</dd><dt><i>fileData</i></dt> +</dd><dt><i>subscription</i></dt> +<dd> +subscription containing the matched rule (AdBlockSubscription) +</dd><dt><i>rule</i></dt> <dd> -reference to the data buffer (QByteArray) -</dd><dt><i>mimeType</i></dt> +matching rule (AdBlockRule) +</dd><dt><i>parent</i></dt> <dd> -for the reply (string) +reference to the parent object (QObject) </dd> </dl><a NAME="AdBlockBlockedNetworkReply.__fireSignals" ID="AdBlockBlockedNetworkReply.__fireSignals"></a> <h4>AdBlockBlockedNetworkReply.__fireSignals</h4>
--- a/Documentation/Source/eric5.Helpviewer.AdBlock.AdBlockManager.html Thu Jul 26 18:38:15 2012 +0200 +++ b/Documentation/Source/eric5.Helpviewer.AdBlock.AdBlockManager.html Sat Jul 28 11:23:12 2012 +0200 @@ -85,6 +85,12 @@ <td><a href="#AdBlockManager.customRules">customRules</a></td> <td>Public method to get a subscription for custom rules.</td> </tr><tr> +<td><a href="#AdBlockManager.elementHidingRules">elementHidingRules</a></td> +<td>Public method to get the element hiding rules.</td> +</tr><tr> +<td><a href="#AdBlockManager.elementHidingRulesForDomain">elementHidingRulesForDomain</a></td> +<td>Public method to get the element hiding rules for a domain.</td> +</tr><tr> <td><a href="#AdBlockManager.isEnabled">isEnabled</a></td> <td>Public method to check, if blocking ads is enabled.</td> </tr><tr> @@ -177,6 +183,31 @@ <dd> subscription object for custom rules (AdBlockSubscription) </dd> +</dl><a NAME="AdBlockManager.elementHidingRules" ID="AdBlockManager.elementHidingRules"></a> +<h4>AdBlockManager.elementHidingRules</h4> +<b>elementHidingRules</b>(<i></i>) +<p> + Public method to get the element hiding rules. +</p><dl> +<dt>Returns:</dt> +<dd> +element hiding rules (string) +</dd> +</dl><a NAME="AdBlockManager.elementHidingRulesForDomain" ID="AdBlockManager.elementHidingRulesForDomain"></a> +<h4>AdBlockManager.elementHidingRulesForDomain</h4> +<b>elementHidingRulesForDomain</b>(<i>url</i>) +<p> + Public method to get the element hiding rules for a domain. +</p><dl> +<dt><i>url</i></dt> +<dd> +URL to get hiding rules for (QUrl) +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +element hiding rules (string) +</dd> </dl><a NAME="AdBlockManager.isEnabled" ID="AdBlockManager.isEnabled"></a> <h4>AdBlockManager.isEnabled</h4> <b>isEnabled</b>(<i></i>)
--- a/Documentation/Source/eric5.Helpviewer.AdBlock.AdBlockNetwork.html Thu Jul 26 18:38:15 2012 +0200 +++ b/Documentation/Source/eric5.Helpviewer.AdBlock.AdBlockNetwork.html Sat Jul 28 11:23:12 2012 +0200 @@ -58,15 +58,36 @@ <h3>Methods</h3> <table> <tr> +<td><a href="#AdBlockNetwork.__canBeBlocked">__canBeBlocked</a></td> +<td>Private method to check, if an URL can be blocked.</td> +</tr><tr> <td><a href="#AdBlockNetwork.block">block</a></td> <td>Public method to check for a network block.</td> +</tr><tr> +<td><a href="#AdBlockNetwork.canRunOnScheme">canRunOnScheme</a></td> +<td>Public method to check, if AdBlock can be performed on the scheme.</td> </tr> </table> <h3>Static Methods</h3> <table> <tr><td>None</td></tr> </table> -<a NAME="AdBlockNetwork.block" ID="AdBlockNetwork.block"></a> +<a NAME="AdBlockNetwork.__canBeBlocked" ID="AdBlockNetwork.__canBeBlocked"></a> +<h4>AdBlockNetwork.__canBeBlocked</h4> +<b>__canBeBlocked</b>(<i>url</i>) +<p> + Private method to check, if an URL can be blocked. +</p><dl> +<dt><i>url</i></dt> +<dd> +URL to be checked (QUrl) +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +flag indicating, that the URL can be blocked (boolean) +</dd> +</dl><a NAME="AdBlockNetwork.block" ID="AdBlockNetwork.block"></a> <h4>AdBlockNetwork.block</h4> <b>block</b>(<i>request</i>) <p> @@ -76,6 +97,21 @@ <dd> reply object (QNetworkReply) or None </dd> +</dl><a NAME="AdBlockNetwork.canRunOnScheme" ID="AdBlockNetwork.canRunOnScheme"></a> +<h4>AdBlockNetwork.canRunOnScheme</h4> +<b>canRunOnScheme</b>(<i>scheme</i>) +<p> + Public method to check, if AdBlock can be performed on the scheme. +</p><dl> +<dt><i>scheme</i></dt> +<dd> +scheme to check (string) +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +flag indicating, that AdBlock can be performed (boolean) +</dd> </dl> <div align="right"><a href="#top">Up</a></div> <hr />
--- a/Documentation/Source/eric5.Helpviewer.AdBlock.AdBlockPage.html Thu Jul 26 18:38:15 2012 +0200 +++ b/Documentation/Source/eric5.Helpviewer.AdBlock.AdBlockPage.html Sat Jul 28 11:23:12 2012 +0200 @@ -33,6 +33,9 @@ <tr> <td><a href="#AdBlockPage">AdBlockPage</a></td> <td>Class to apply AdBlock rules to a web page.</td> +</tr><tr> +<td><a href="#AdBlockedPageEntry">AdBlockedPageEntry</a></td> +<td>Class implementing a data structure for web page rules.</td> </tr> </table> <h3>Functions</h3> @@ -58,42 +61,96 @@ <h3>Methods</h3> <table> <tr> -<td><a href="#AdBlockPage.__checkRule">__checkRule</a></td> -<td>Private method to check, if a rule applies to the given web page and host.</td> -</tr><tr> -<td><a href="#AdBlockPage.applyRulesToPage">applyRulesToPage</a></td> -<td>Public method to applay AdBlock rules to a web page.</td> +<td><a href="#AdBlockPage.hideBlockedPageEntries">hideBlockedPageEntries</a></td> +<td>Public method to apply AdBlock rules to a web page.</td> </tr> </table> <h3>Static Methods</h3> <table> <tr><td>None</td></tr> </table> -<a NAME="AdBlockPage.__checkRule" ID="AdBlockPage.__checkRule"></a> -<h4>AdBlockPage.__checkRule</h4> -<b>__checkRule</b>(<i>rule, page, host</i>) +<a NAME="AdBlockPage.hideBlockedPageEntries" ID="AdBlockPage.hideBlockedPageEntries"></a> +<h4>AdBlockPage.hideBlockedPageEntries</h4> +<b>hideBlockedPageEntries</b>(<i>page</i>) +<p> + Public method to apply AdBlock rules to a web page. +</p><dl> +<dt><i>page</i></dt> +<dd> +reference to the web page (HelpWebPage) +</dd> +</dl> +<div align="right"><a href="#top">Up</a></div> +<hr /><hr /> +<a NAME="AdBlockedPageEntry" ID="AdBlockedPageEntry"></a> +<h2>AdBlockedPageEntry</h2> <p> - Private method to check, if a rule applies to the given web page and host. + Class implementing a data structure for web page rules. +</p> +<h3>Derived from</h3> +object +<h3>Class Attributes</h3> +<table> +<tr><td>None</td></tr> +</table> +<h3>Class Methods</h3> +<table> +<tr><td>None</td></tr> +</table> +<h3>Methods</h3> +<table> +<tr> +<td><a href="#AdBlockedPageEntry.__init__">AdBlockedPageEntry</a></td> +<td>Constructor</td> +</tr><tr> +<td><a href="#AdBlockedPageEntry.__eq__">__eq__</a></td> +<td>Special method to test equality.</td> +</tr><tr> +<td><a href="#AdBlockedPageEntry.urlString">urlString</a></td> +<td>Public method to get the URL as a string.</td> +</tr> +</table> +<h3>Static Methods</h3> +<table> +<tr><td>None</td></tr> +</table> +<a NAME="AdBlockedPageEntry.__init__" ID="AdBlockedPageEntry.__init__"></a> +<h4>AdBlockedPageEntry (Constructor)</h4> +<b>AdBlockedPageEntry</b>(<i>rule, url</i>) +<p> + Constructor </p><dl> <dt><i>rule</i></dt> <dd> -reference to the rule to check (AdBlockRule) -</dd><dt><i>page</i></dt> +AdBlock rule to add (AdBlockRule) +</dd><dt><i>url</i></dt> <dd> -reference to the web page (QWebPage) -</dd><dt><i>host</i></dt> +URL that matched the rule (QUrl) +</dd> +</dl><a NAME="AdBlockedPageEntry.__eq__" ID="AdBlockedPageEntry.__eq__"></a> +<h4>AdBlockedPageEntry.__eq__</h4> +<b>__eq__</b>(<i>other</i>) +<p> + Special method to test equality. +</p><dl> +<dt><i>other</i></dt> <dd> -host name (string) +reference to the other entry (AdBlockedPageEntry) </dd> -</dl><a NAME="AdBlockPage.applyRulesToPage" ID="AdBlockPage.applyRulesToPage"></a> -<h4>AdBlockPage.applyRulesToPage</h4> -<b>applyRulesToPage</b>(<i>page</i>) +</dl><dl> +<dt>Returns:</dt> +<dd> +flag indicating equality (boolean) +</dd> +</dl><a NAME="AdBlockedPageEntry.urlString" ID="AdBlockedPageEntry.urlString"></a> +<h4>AdBlockedPageEntry.urlString</h4> +<b>urlString</b>(<i></i>) <p> - Public method to applay AdBlock rules to a web page. + Public method to get the URL as a string. </p><dl> -<dt><i>page</i></dt> +<dt>Returns:</dt> <dd> -reference to the web page (QWebPage) +URL as a string (string) </dd> </dl> <div align="right"><a href="#top">Up</a></div>
--- a/Documentation/Source/eric5.Helpviewer.AdBlock.AdBlockRule.html Thu Jul 26 18:38:15 2012 +0200 +++ b/Documentation/Source/eric5.Helpviewer.AdBlock.AdBlockRule.html Sat Jul 28 11:23:12 2012 +0200 @@ -37,7 +37,10 @@ </table> <h3>Functions</h3> <table> -<tr><td>None</td></tr> +<tr> +<td><a href="#toSecondLevelDomain">toSecondLevelDomain</a></td> +<td>Module function to get a second level domain from the given URL.</td> +</tr> </table> <hr /><hr /> <a NAME="AdBlockRule" ID="AdBlockRule"></a> @@ -64,24 +67,63 @@ <td><a href="#AdBlockRule.__convertPatternToRegExp">__convertPatternToRegExp</a></td> <td>Private method to convert a wildcard pattern to a regular expression.</td> </tr><tr> +<td><a href="#AdBlockRule.__parseDomains">__parseDomains</a></td> +<td>Private method to parse a string with a domain list.</td> +</tr><tr> +<td><a href="#AdBlockRule.__parseFilter">__parseFilter</a></td> +<td>Private method to parse the filter pattern.</td> +</tr><tr> +<td><a href="#AdBlockRule.cssSelector">cssSelector</a></td> +<td>Public method to get the CSS selector of the rule.</td> +</tr><tr> <td><a href="#AdBlockRule.filter">filter</a></td> <td>Public method to get the rule filter string.</td> </tr><tr> <td><a href="#AdBlockRule.isCSSRule">isCSSRule</a></td> <td>Public method to check, if the rule is a CSS rule.</td> </tr><tr> +<td><a href="#AdBlockRule.isComment">isComment</a></td> +<td>Public method to check, if this is a comment.</td> +</tr><tr> +<td><a href="#AdBlockRule.isDocument">isDocument</a></td> +<td>Public method to check, if this is a document rule.</td> +</tr><tr> +<td><a href="#AdBlockRule.isDomainRestricted">isDomainRestricted</a></td> +<td>Public method to check, if this rule is restricted by domain.</td> +</tr><tr> +<td><a href="#AdBlockRule.isElementHiding">isElementHiding</a></td> +<td>Public method to check, if this is an element hiding rule.</td> +</tr><tr> <td><a href="#AdBlockRule.isEnabled">isEnabled</a></td> <td>Public method to check, if the rule is enabled.</td> </tr><tr> <td><a href="#AdBlockRule.isException">isException</a></td> <td>Public method to check, if the rule defines an exception.</td> </tr><tr> +<td><a href="#AdBlockRule.isInternalDisabled">isInternalDisabled</a></td> +<td>Public method to check, if this rule was disabled internally.</td> +</tr><tr> +<td><a href="#AdBlockRule.isSlow">isSlow</a></td> +<td>Public method to check, if this is a slow rule.</td> +</tr><tr> +<td><a href="#AdBlockRule.matchDomain">matchDomain</a></td> +<td>Public method to match a domain.</td> +</tr><tr> +<td><a href="#AdBlockRule.matchObject">matchObject</a></td> +<td>Public slot to match an object rule.</td> +</tr><tr> +<td><a href="#AdBlockRule.matchSubdocument">matchSubdocument</a></td> +<td>Public slot to match a sub-document rule.</td> +</tr><tr> +<td><a href="#AdBlockRule.matchThirdParty">matchThirdParty</a></td> +<td>Public slot to match a third-party rule.</td> +</tr><tr> +<td><a href="#AdBlockRule.matchXmlHttpRequest">matchXmlHttpRequest</a></td> +<td>Public slot to match a XmlHttpRequest rule.</td> +</tr><tr> <td><a href="#AdBlockRule.networkMatch">networkMatch</a></td> <td>Public method to check the rule for a match.</td> </tr><tr> -<td><a href="#AdBlockRule.regExpPattern">regExpPattern</a></td> -<td>Public method to get the regexp pattern of the rule.</td> -</tr><tr> <td><a href="#AdBlockRule.setEnabled">setEnabled</a></td> <td>Public method to set the rule's enabled state.</td> </tr><tr> @@ -91,8 +133,8 @@ <td><a href="#AdBlockRule.setFilter">setFilter</a></td> <td>Public method to set the rule filter string.</td> </tr><tr> -<td><a href="#AdBlockRule.setPattern">setPattern</a></td> -<td>Public method to set the rule pattern.</td> +<td><a href="#AdBlockRule.urlMatch">urlMatch</a></td> +<td>Public method to check an URL against the rule.</td> </tr> </table> <h3>Static Methods</h3> @@ -119,6 +161,34 @@ <dd> string containing a regular expression (string) </dd> +</dl><a NAME="AdBlockRule.__parseDomains" ID="AdBlockRule.__parseDomains"></a> +<h4>AdBlockRule.__parseDomains</h4> +<b>__parseDomains</b>(<i>domains, separator</i>) +<p> + Private method to parse a string with a domain list. +</p><dl> +<dt><i>domains</i></dt> +<dd> +list of domains (string) +</dd><dt><i>separator</i></dt> +<dd> +separator character used by the list (string) +</dd> +</dl><a NAME="AdBlockRule.__parseFilter" ID="AdBlockRule.__parseFilter"></a> +<h4>AdBlockRule.__parseFilter</h4> +<b>__parseFilter</b>(<i></i>) +<p> + Private method to parse the filter pattern. +</p><a NAME="AdBlockRule.cssSelector" ID="AdBlockRule.cssSelector"></a> +<h4>AdBlockRule.cssSelector</h4> +<b>cssSelector</b>(<i></i>) +<p> + Public method to get the CSS selector of the rule. +</p><dl> +<dt>Returns:</dt> +<dd> +CSS selector (string) +</dd> </dl><a NAME="AdBlockRule.filter" ID="AdBlockRule.filter"></a> <h4>AdBlockRule.filter</h4> <b>filter</b>(<i></i>) @@ -139,6 +209,46 @@ <dd> flag indicating a CSS rule (boolean) </dd> +</dl><a NAME="AdBlockRule.isComment" ID="AdBlockRule.isComment"></a> +<h4>AdBlockRule.isComment</h4> +<b>isComment</b>(<i></i>) +<p> + Public method to check, if this is a comment. +</p><dl> +<dt>Returns:</dt> +<dd> +flag indicating a comment (boolean) +</dd> +</dl><a NAME="AdBlockRule.isDocument" ID="AdBlockRule.isDocument"></a> +<h4>AdBlockRule.isDocument</h4> +<b>isDocument</b>(<i></i>) +<p> + Public method to check, if this is a document rule. +</p><dl> +<dt>Returns:</dt> +<dd> +flag indicating a document rule (boolean) +</dd> +</dl><a NAME="AdBlockRule.isDomainRestricted" ID="AdBlockRule.isDomainRestricted"></a> +<h4>AdBlockRule.isDomainRestricted</h4> +<b>isDomainRestricted</b>(<i></i>) +<p> + Public method to check, if this rule is restricted by domain. +</p><dl> +<dt>Returns:</dt> +<dd> +flag indicating a domain restriction (boolean) +</dd> +</dl><a NAME="AdBlockRule.isElementHiding" ID="AdBlockRule.isElementHiding"></a> +<h4>AdBlockRule.isElementHiding</h4> +<b>isElementHiding</b>(<i></i>) +<p> + Public method to check, if this is an element hiding rule. +</p><dl> +<dt>Returns:</dt> +<dd> +flag indicating an element hiding rule (boolean) +</dd> </dl><a NAME="AdBlockRule.isEnabled" ID="AdBlockRule.isEnabled"></a> <h4>AdBlockRule.isEnabled</h4> <b>isEnabled</b>(<i></i>) @@ -159,13 +269,114 @@ <dd> flag indicating an exception (boolean) </dd> +</dl><a NAME="AdBlockRule.isInternalDisabled" ID="AdBlockRule.isInternalDisabled"></a> +<h4>AdBlockRule.isInternalDisabled</h4> +<b>isInternalDisabled</b>(<i></i>) +<p> + Public method to check, if this rule was disabled internally. +</p><dl> +<dt>Returns:</dt> +<dd> +flag indicating an internally disabled rule (boolean) +</dd> +</dl><a NAME="AdBlockRule.isSlow" ID="AdBlockRule.isSlow"></a> +<h4>AdBlockRule.isSlow</h4> +<b>isSlow</b>(<i></i>) +<p> + Public method to check, if this is a slow rule. +</p><dl> +<dt>Returns:</dt> +<dd> +flag indicating a slow rule (boolean) +</dd> +</dl><a NAME="AdBlockRule.matchDomain" ID="AdBlockRule.matchDomain"></a> +<h4>AdBlockRule.matchDomain</h4> +<b>matchDomain</b>(<i>domain</i>) +<p> + Public method to match a domain. +</p><dl> +<dt><i>domain</i></dt> +<dd> +domain name to check (string) +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +flag indicating a match (boolean) +</dd> +</dl><a NAME="AdBlockRule.matchObject" ID="AdBlockRule.matchObject"></a> +<h4>AdBlockRule.matchObject</h4> +<b>matchObject</b>(<i>req</i>) +<p> + Public slot to match an object rule. +</p><dl> +<dt><i>req</i></dt> +<dd> +request object to check (QNetworkRequest) +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +flag indicating a match (boolean) +</dd> +</dl><a NAME="AdBlockRule.matchSubdocument" ID="AdBlockRule.matchSubdocument"></a> +<h4>AdBlockRule.matchSubdocument</h4> +<b>matchSubdocument</b>(<i>req</i>) +<p> + Public slot to match a sub-document rule. +</p><dl> +<dt><i>req</i></dt> +<dd> +request object to check (QNetworkRequest) +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +flag indicating a match (boolean) +</dd> +</dl><a NAME="AdBlockRule.matchThirdParty" ID="AdBlockRule.matchThirdParty"></a> +<h4>AdBlockRule.matchThirdParty</h4> +<b>matchThirdParty</b>(<i>req</i>) +<p> + Public slot to match a third-party rule. +</p><dl> +<dt><i>req</i></dt> +<dd> +request object to check (QNetworkRequest) +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +flag indicating a match (boolean) +</dd> +</dl><a NAME="AdBlockRule.matchXmlHttpRequest" ID="AdBlockRule.matchXmlHttpRequest"></a> +<h4>AdBlockRule.matchXmlHttpRequest</h4> +<b>matchXmlHttpRequest</b>(<i>req</i>) +<p> + Public slot to match a XmlHttpRequest rule. +</p><dl> +<dt><i>req</i></dt> +<dd> +request object to check (QNetworkRequest) +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +flag indicating a match (boolean) +</dd> </dl><a NAME="AdBlockRule.networkMatch" ID="AdBlockRule.networkMatch"></a> <h4>AdBlockRule.networkMatch</h4> -<b>networkMatch</b>(<i>encodedUrl</i>) +<b>networkMatch</b>(<i>request, domain, encodedUrl</i>) <p> Public method to check the rule for a match. </p><dl> -<dt><i>encodedUrl</i></dt> +<dt><i>request</i></dt> +<dd> +reference to the network request (QNetworkRequest) +</dd><dt><i>domain</i></dt> +<dd> +domain name (string) +</dd><dt><i>encodedUrl</i></dt> <dd> string encoded URL to be checked (string) </dd> @@ -174,16 +385,6 @@ <dd> flag indicating a match (boolean) </dd> -</dl><a NAME="AdBlockRule.regExpPattern" ID="AdBlockRule.regExpPattern"></a> -<h4>AdBlockRule.regExpPattern</h4> -<b>regExpPattern</b>(<i></i>) -<p> - Public method to get the regexp pattern of the rule. -</p><dl> -<dt>Returns:</dt> -<dd> -regexp pattern (QRegExp) -</dd> </dl><a NAME="AdBlockRule.setEnabled" ID="AdBlockRule.setEnabled"></a> <h4>AdBlockRule.setEnabled</h4> <b>setEnabled</b>(<i>enabled</i>) @@ -214,18 +415,38 @@ <dd> rule filter string (string) </dd> -</dl><a NAME="AdBlockRule.setPattern" ID="AdBlockRule.setPattern"></a> -<h4>AdBlockRule.setPattern</h4> -<b>setPattern</b>(<i>pattern, isRegExp</i>) +</dl><a NAME="AdBlockRule.urlMatch" ID="AdBlockRule.urlMatch"></a> +<h4>AdBlockRule.urlMatch</h4> +<b>urlMatch</b>(<i>url</i>) <p> - Public method to set the rule pattern. + Public method to check an URL against the rule. </p><dl> -<dt><i>pattern</i></dt> +<dt><i>url</i></dt> +<dd> +URL to check (QUrl) +</dd> +</dl><dl> +<dt>Returns:</dt> <dd> -string containing the pattern (string) -</dd><dt><i>isRegExp</i></dt> +flag indicating a match (boolean) +</dd> +</dl> +<div align="right"><a href="#top">Up</a></div> +<hr /><hr /> +<a NAME="toSecondLevelDomain" ID="toSecondLevelDomain"></a> +<h2>toSecondLevelDomain</h2> +<b>toSecondLevelDomain</b>(<i>url</i>) +<p> + Module function to get a second level domain from the given URL. +</p><dl> +<dt><i>url</i></dt> <dd> -flag indicating a reg exp pattern (boolean) +URL to extract domain from (QUrl) +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +name of second level domain (string) </dd> </dl> <div align="right"><a href="#top">Up</a></div>
--- a/Documentation/Source/eric5.Helpviewer.AdBlock.AdBlockSubscription.html Thu Jul 26 18:38:15 2012 +0200 +++ b/Documentation/Source/eric5.Helpviewer.AdBlock.AdBlockSubscription.html Sat Jul 28 11:23:12 2012 +0200 @@ -82,21 +82,27 @@ <td><a href="#AdBlockSubscription.__rulesDownloaded">__rulesDownloaded</a></td> <td>Private slot to deal with the downloaded rules.</td> </tr><tr> +<td><a href="#AdBlockSubscription.adBlockDisabledForUrl">adBlockDisabledForUrl</a></td> +<td>Public method to check, if AdBlock is disabled for the given URL.</td> +</tr><tr> <td><a href="#AdBlockSubscription.addRule">addRule</a></td> <td>Public method to add a rule.</td> </tr><tr> <td><a href="#AdBlockSubscription.allRules">allRules</a></td> <td>Public method to get the list of rules.</td> </tr><tr> -<td><a href="#AdBlockSubscription.allow">allow</a></td> -<td>Public method to check, if the given URL is allowed.</td> -</tr><tr> -<td><a href="#AdBlockSubscription.block">block</a></td> -<td>Public method to check, if the given URL should be blocked.</td> -</tr><tr> <td><a href="#AdBlockSubscription.checkForUpdate">checkForUpdate</a></td> <td>Public method to check for an update.</td> </tr><tr> +<td><a href="#AdBlockSubscription.elemHideDisabledForUrl">elemHideDisabledForUrl</a></td> +<td>Public method to check, if element hiding is disabled for the given URL.</td> +</tr><tr> +<td><a href="#AdBlockSubscription.elementHidingRules">elementHidingRules</a></td> +<td>Public method to get the element hiding rules.</td> +</tr><tr> +<td><a href="#AdBlockSubscription.elementHidingRulesForDomain">elementHidingRulesForDomain</a></td> +<td>Public method to get the element hiding rules for the given domain.</td> +</tr><tr> <td><a href="#AdBlockSubscription.isEnabled">isEnabled</a></td> <td>Public method to check, if the subscription is enabled.</td> </tr><tr> @@ -106,8 +112,8 @@ <td><a href="#AdBlockSubscription.location">location</a></td> <td>Public method to get the subscription location.</td> </tr><tr> -<td><a href="#AdBlockSubscription.pageRules">pageRules</a></td> -<td>Public method to get the page rules of the subscription.</td> +<td><a href="#AdBlockSubscription.match">match</a></td> +<td>Public method to check the subscription for a matching rule.</td> </tr><tr> <td><a href="#AdBlockSubscription.removeRule">removeRule</a></td> <td>Public method to remove a rule given the offset.</td> @@ -137,7 +143,7 @@ <td>Public method to update the subscription immediately.</td> </tr><tr> <td><a href="#AdBlockSubscription.url">url</a></td> -<td>Public method to generate the url for this subscription.</td> +<td>Public method to generate the URL for this subscription.</td> </tr> </table> <h3>Static Methods</h3> @@ -185,7 +191,22 @@ <b>__rulesDownloaded</b>(<i></i>) <p> Private slot to deal with the downloaded rules. -</p><a NAME="AdBlockSubscription.addRule" ID="AdBlockSubscription.addRule"></a> +</p><a NAME="AdBlockSubscription.adBlockDisabledForUrl" ID="AdBlockSubscription.adBlockDisabledForUrl"></a> +<h4>AdBlockSubscription.adBlockDisabledForUrl</h4> +<b>adBlockDisabledForUrl</b>(<i>url</i>) +<p> + Public method to check, if AdBlock is disabled for the given URL. +</p><dl> +<dt><i>url</i></dt> +<dd> +URL to check (QUrl) +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +flag indicating disabled state (boolean) +</dd> +</dl><a NAME="AdBlockSubscription.addRule" ID="AdBlockSubscription.addRule"></a> <h4>AdBlockSubscription.addRule</h4> <b>addRule</b>(<i>rule</i>) <p> @@ -205,32 +226,52 @@ <dd> list of rules (list of AdBlockRule) </dd> -</dl><a NAME="AdBlockSubscription.allow" ID="AdBlockSubscription.allow"></a> -<h4>AdBlockSubscription.allow</h4> -<b>allow</b>(<i>urlString</i>) -<p> - Public method to check, if the given URL is allowed. -</p><dl> -<dt>Returns:</dt> -<dd> -reference to the rule object or None (AdBlockRule) -</dd> -</dl><a NAME="AdBlockSubscription.block" ID="AdBlockSubscription.block"></a> -<h4>AdBlockSubscription.block</h4> -<b>block</b>(<i>urlString</i>) -<p> - Public method to check, if the given URL should be blocked. -</p><dl> -<dt>Returns:</dt> -<dd> -reference to the rule object or None (AdBlockRule) -</dd> </dl><a NAME="AdBlockSubscription.checkForUpdate" ID="AdBlockSubscription.checkForUpdate"></a> <h4>AdBlockSubscription.checkForUpdate</h4> <b>checkForUpdate</b>(<i></i>) <p> Public method to check for an update. -</p><a NAME="AdBlockSubscription.isEnabled" ID="AdBlockSubscription.isEnabled"></a> +</p><a NAME="AdBlockSubscription.elemHideDisabledForUrl" ID="AdBlockSubscription.elemHideDisabledForUrl"></a> +<h4>AdBlockSubscription.elemHideDisabledForUrl</h4> +<b>elemHideDisabledForUrl</b>(<i>url</i>) +<p> + Public method to check, if element hiding is disabled for the given URL. +</p><dl> +<dt><i>url</i></dt> +<dd> +URL to check (QUrl) +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +flag indicating disabled state (boolean) +</dd> +</dl><a NAME="AdBlockSubscription.elementHidingRules" ID="AdBlockSubscription.elementHidingRules"></a> +<h4>AdBlockSubscription.elementHidingRules</h4> +<b>elementHidingRules</b>(<i></i>) +<p> + Public method to get the element hiding rules. +</p><dl> +<dt>Returns:</dt> +<dd> +element hiding rules (string) +</dd> +</dl><a NAME="AdBlockSubscription.elementHidingRulesForDomain" ID="AdBlockSubscription.elementHidingRulesForDomain"></a> +<h4>AdBlockSubscription.elementHidingRulesForDomain</h4> +<b>elementHidingRulesForDomain</b>(<i>domain</i>) +<p> + Public method to get the element hiding rules for the given domain. +</p><dl> +<dt><i>domain</i></dt> +<dd> +domain name (string) +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +element hiding rules (string) +</dd> +</dl><a NAME="AdBlockSubscription.isEnabled" ID="AdBlockSubscription.isEnabled"></a> <h4>AdBlockSubscription.isEnabled</h4> <b>isEnabled</b>(<i></i>) <p> @@ -260,15 +301,26 @@ <dd> URL of the subscription location (QUrl) </dd> -</dl><a NAME="AdBlockSubscription.pageRules" ID="AdBlockSubscription.pageRules"></a> -<h4>AdBlockSubscription.pageRules</h4> -<b>pageRules</b>(<i></i>) +</dl><a NAME="AdBlockSubscription.match" ID="AdBlockSubscription.match"></a> +<h4>AdBlockSubscription.match</h4> +<b>match</b>(<i>req, urlDomain, urlString</i>) <p> - Public method to get the page rules of the subscription. + Public method to check the subscription for a matching rule. </p><dl> +<dt><i>req</i></dt> +<dd> +reference to the network request (QNetworkRequest) +</dd><dt><i>urlDomain</i></dt> +<dd> +domain of the URL (string) +</dd><dt><i>urlString</i></dt> +<dd> +URL (string) +</dd> +</dl><dl> <dt>Returns:</dt> <dd> -list of rule objects (list of AdBlockRule) +reference to the rule object or None (AdBlockRule) </dd> </dl><a NAME="AdBlockSubscription.removeRule" ID="AdBlockSubscription.removeRule"></a> <h4>AdBlockSubscription.removeRule</h4> @@ -357,7 +409,7 @@ <h4>AdBlockSubscription.url</h4> <b>url</b>(<i></i>) <p> - Public method to generate the url for this subscription. + Public method to generate the URL for this subscription. </p><dl> <dt>Returns:</dt> <dd>
--- a/Documentation/Source/eric5.Helpviewer.HelpBrowserWV.html Thu Jul 26 18:38:15 2012 +0200 +++ b/Documentation/Source/eric5.Helpviewer.HelpBrowserWV.html Sat Jul 28 11:23:12 2012 +0200 @@ -1107,18 +1107,27 @@ <td><a href="#HelpWebPage.__init__">HelpWebPage</a></td> <td>Constructor</td> </tr><tr> +<td><a href="#HelpWebPage.__loadStarted">__loadStarted</a></td> +<td>Private method to handle the loadStarted signal.</td> +</tr><tr> <td><a href="#HelpWebPage.__managerFinished">__managerFinished</a></td> <td>Private slot to handle a finished reply.</td> </tr><tr> <td><a href="#HelpWebPage.acceptNavigationRequest">acceptNavigationRequest</a></td> <td>Protected method to determine, if a request may be accepted.</td> </tr><tr> +<td><a href="#HelpWebPage.addAdBlockRule">addAdBlockRule</a></td> +<td>Public slot to add an AdBlock rule to the page.</td> +</tr><tr> <td><a href="#HelpWebPage.event">event</a></td> <td>Protected method implementing the event handler.</td> </tr><tr> <td><a href="#HelpWebPage.extension">extension</a></td> <td>Public method to implement a specific extension.</td> </tr><tr> +<td><a href="#HelpWebPage.getAdBlockedPageEntries">getAdBlockedPageEntries</a></td> +<td>Public method to get the list of AdBlock page entries.</td> +</tr><tr> <td><a href="#HelpWebPage.getSslInfo">getSslInfo</a></td> <td>Public method to get a reference to the SSL info object.</td> </tr><tr> @@ -1140,6 +1149,9 @@ <td><a href="#HelpWebPage.supportsExtension">supportsExtension</a></td> <td>Public method to check the support for an extension.</td> </tr><tr> +<td><a href="#HelpWebPage.url">url</a></td> +<td>Public method to get the URL of the page.</td> +</tr><tr> <td><a href="#HelpWebPage.userAgent">userAgent</a></td> <td>Public method to get the global user agent setting.</td> </tr><tr> @@ -1171,7 +1183,12 @@ <dd> parent widget of this window (QWidget) </dd> -</dl><a NAME="HelpWebPage.__managerFinished" ID="HelpWebPage.__managerFinished"></a> +</dl><a NAME="HelpWebPage.__loadStarted" ID="HelpWebPage.__loadStarted"></a> +<h4>HelpWebPage.__loadStarted</h4> +<b>__loadStarted</b>(<i></i>) +<p> + Private method to handle the loadStarted signal. +</p><a NAME="HelpWebPage.__managerFinished" ID="HelpWebPage.__managerFinished"></a> <h4>HelpWebPage.__managerFinished</h4> <b>__managerFinished</b>(<i>reply</i>) <p> @@ -1204,6 +1221,19 @@ <dd> flag indicating acceptance (boolean) </dd> +</dl><a NAME="HelpWebPage.addAdBlockRule" ID="HelpWebPage.addAdBlockRule"></a> +<h4>HelpWebPage.addAdBlockRule</h4> +<b>addAdBlockRule</b>(<i>rule, url</i>) +<p> + Public slot to add an AdBlock rule to the page. +</p><dl> +<dt><i>rule</i></dt> +<dd> +AdBlock rule to add (AdBlockRule) +</dd><dt><i>url</i></dt> +<dd> +URL that matched the rule (QUrl) +</dd> </dl><a NAME="HelpWebPage.event" ID="HelpWebPage.event"></a> <h4>HelpWebPage.event</h4> <b>event</b>(<i>evt</i>) @@ -1240,6 +1270,16 @@ <dd> flag indicating a successful call of the extension (boolean) </dd> +</dl><a NAME="HelpWebPage.getAdBlockedPageEntries" ID="HelpWebPage.getAdBlockedPageEntries"></a> +<h4>HelpWebPage.getAdBlockedPageEntries</h4> +<b>getAdBlockedPageEntries</b>(<i></i>) +<p> + Public method to get the list of AdBlock page entries. +</p><dl> +<dt>Returns:</dt> +<dd> +list of AdBlock page entries (list of AdBlockedPageEntry) +</dd> </dl><a NAME="HelpWebPage.getSslInfo" ID="HelpWebPage.getSslInfo"></a> <h4>HelpWebPage.getSslInfo</h4> <b>getSslInfo</b>(<i></i>) @@ -1310,6 +1350,16 @@ <dd> flag indicating the support of extension (boolean) </dd> +</dl><a NAME="HelpWebPage.url" ID="HelpWebPage.url"></a> +<h4>HelpWebPage.url</h4> +<b>url</b>(<i></i>) +<p> + Public method to get the URL of the page. +</p><dl> +<dt>Returns:</dt> +<dd> +URL of the page (QUrl) +</dd> </dl><a NAME="HelpWebPage.userAgent" ID="HelpWebPage.userAgent"></a> <h4>HelpWebPage.userAgent</h4> <b>userAgent</b>(<i>resolveEmpty=False</i>)
--- a/Helpviewer/AdBlock/AdBlockBlockedNetworkReply.py Thu Jul 26 18:38:15 2012 +0200 +++ b/Helpviewer/AdBlock/AdBlockBlockedNetworkReply.py Sat Jul 28 11:23:12 2012 +0200 @@ -15,20 +15,21 @@ """ Class implementing a QNetworkReply subclass reporting a blocked request. """ - def __init__(self, request, rule, parent=None): + def __init__(self, request, subscription, rule, parent=None): """ Constructor @param request reference to the request object (QNetworkRequest) - @param fileData reference to the data buffer (QByteArray) - @param mimeType for the reply (string) + @param subscription subscription containing the matched rule (AdBlockSubscription) + @param rule matching rule (AdBlockRule) + @param parent reference to the parent object (QObject) """ super().__init__(parent) self.setOperation(QNetworkAccessManager.GetOperation) self.setRequest(request) self.setUrl(request.url()) self.setError(QNetworkReply.ContentAccessDenied, - "AdBlockRule:{0}".format(rule.filter())) + "AdBlockRule:{0} ({1})".format(subscription.title(), rule.filter())) QTimer.singleShot(0, self.__fireSignals) def __fireSignals(self):
--- a/Helpviewer/AdBlock/AdBlockManager.py Thu Jul 26 18:38:15 2012 +0200 +++ b/Helpviewer/AdBlock/AdBlockManager.py Sat Jul 28 11:23:12 2012 +0200 @@ -249,3 +249,47 @@ self.__adBlockDialog.show() return self.__adBlockDialog + + def elementHidingRules(self): + """ + Public method to get the element hiding rules. + + @return element hiding rules (string) + """ + if not self.__enabled: + return "" + + rules = "" + + for subscription in self.__subscriptions: + rules += subscription.elementHidingRules() + + if rules: + # remove last ", + rules = rules[:-1] + + return rules + + def elementHidingRulesForDomain(self, url): + """ + Public method to get the element hiding rules for a domain. + + @param url URL to get hiding rules for (QUrl) + @return element hiding rules (string) + """ + if not self.__enabled: + return "" + + rules = "" + + for subscription in self.__subscriptions: + if subscription.elemHideDisabledForUrl(url): + return "" + + rules += subscription.elementHidingRulesForDomain(url.host()) + + if rules: + # remove last ", + rules = rules[:-1] + + return rules
--- a/Helpviewer/AdBlock/AdBlockNetwork.py Thu Jul 26 18:38:15 2012 +0200 +++ b/Helpviewer/AdBlock/AdBlockNetwork.py Sat Jul 28 11:23:12 2012 +0200 @@ -8,6 +8,7 @@ """ from PyQt4.QtCore import QObject +from PyQt4.QtNetwork import QNetworkRequest import Helpviewer.HelpWindow @@ -25,28 +26,48 @@ @return reply object (QNetworkReply) or None """ url = request.url() - - if url.scheme() in ["data", "eric", "qthelp", "qrc", "file", "abp"]: - return None + urlString = bytes(url.toEncoded()).decode() + urlDomain = url.host() + urlScheme = url.scheme() manager = Helpviewer.HelpWindow.HelpWindow.adblockManager() - if not manager.isEnabled(): + if not manager.isEnabled() or not self.canRunOnScheme(urlScheme): return None - urlString = bytes(url.toEncoded()).decode() - blockedRule = None - for subscription in manager.subscriptions(): - if subscription.allow(urlString): - return None - - rule = subscription.block(urlString) - if rule is not None: - blockedRule = rule - break - - if blockedRule is not None: - reply = AdBlockBlockedNetworkReply(request, blockedRule, self) - return reply + blockedRule = subscription.match(request, urlDomain, urlString) + if blockedRule: + webPage = request.attribute(QNetworkRequest.User + 100) + if webPage is not None: + if not self.__canBeBlocked(webPage.url()): + return None + + webPage.addAdBlockRule(blockedRule, url) + + reply = AdBlockBlockedNetworkReply(request, subscription, blockedRule, self) + return reply return None + + def canRunOnScheme(self, scheme): + """ + Public method to check, if AdBlock can be performed on the scheme. + + @param scheme scheme to check (string) + @return flag indicating, that AdBlock can be performed (boolean) + """ + return scheme not in ["data", "eric", "qthelp", "qrc", "file", "abp"] + + def __canBeBlocked(self, url): + """ + Private method to check, if an URL can be blocked. + + @param url URL to be checked (QUrl) + @return flag indicating, that the URL can be blocked (boolean) + """ + manager = Helpviewer.HelpWindow.HelpWindow.adblockManager() + for subscription in manager.subscriptions(): + if subscription.adBlockDisabledForUrl(url): + return False + + return True
--- a/Helpviewer/AdBlock/AdBlockPage.py Thu Jul 26 18:38:15 2012 +0200 +++ b/Helpviewer/AdBlock/AdBlockPage.py Sat Jul 28 11:23:12 2012 +0200 @@ -7,7 +7,7 @@ Module implementing a class to apply AdBlock rules to a web page. """ -from PyQt4.QtCore import QObject +from PyQt4.QtCore import QObject, QUrl import Helpviewer.HelpWindow @@ -16,55 +16,11 @@ """ Class to apply AdBlock rules to a web page. """ - def __checkRule(self, rule, page, host): - """ - Private method to check, if a rule applies to the given web page and host. - - @param rule reference to the rule to check (AdBlockRule) - @param page reference to the web page (QWebPage) - @param host host name (string) + def hideBlockedPageEntries(self, page): """ - if not rule.isEnabled(): - return - - filter = rule.filter() - offset = filter.find("##") - if offset == -1: - return + Public method to apply AdBlock rules to a web page. - selectorQuery = "" - if offset > 0: - domainRules = filter[:offset] - selectorQuery = filter[offset + 2:] - domains = domainRules.split(",") - - match = False - for domain in domains: - reverse = domain[0] == '~' - if reverse: - xdomain = domain[1:] - if host.endswith(xdomain): - return - match = True - if host.endswith(domain): - match = True - if not match: - return - - if offset == 0: - selectorQuery = filter[2:] - - document = page.mainFrame().documentElement() - elements = document.findAll(selectorQuery) - for element in elements.toList(): - element.setStyleProperty("visibility", "hidden") - element.removeFromDocument() - - def applyRulesToPage(self, page): - """ - Public method to applay AdBlock rules to a web page. - - @param page reference to the web page (QWebPage) + @param page reference to the web page (HelpWebPage) """ if page is None or page.mainFrame() is None: return @@ -73,9 +29,69 @@ if not manager.isEnabled(): return - host = page.mainFrame().url().host() - subscriptions = manager.subscriptions() - for subscription in subscriptions: - rules = subscription.pageRules() - for rule in rules: - self.__checkRule(rule, page, host) + docElement = page.mainFrame().documentElement() + + for entry in page.getAdBlockedPageEntries(): + urlString = entry.urlString() + if urlString.endswith((".js", ".css")): + continue + + urlEnd = "" + pos = urlString.rfind("/") + if pos >= 0: + urlEnd = urlString[pos + 1:] + if urlString.endswith("/"): + urlEnd = urlString[:-1] + + selector = 'img[src$="{0}"], iframe[src$="{0}"], embed[src$="{0}"]'\ + .format(urlEnd) + elements = docElement.findAll(selector) + + for element in elements: + src = element.attribute("src") + src = src.replace("../", "") + if src in urlString: + element.setStyleProperty("display", "none") + + # apply domain specific element hiding rules + elementHiding = manager.elementHidingRulesForDomain(page.url()) + if not elementHiding: + return + + elementHiding += "{display: none !important;}\n</style>" + + bodyElement = docElement.findFirst("body") + bodyElement.appendInside('<style type="text/css">\n/* AdBlock for eric */\n' + + elementHiding) + + +class AdBlockedPageEntry(object): + """ + Class implementing a data structure for web page rules. + """ + def __init__(self, rule, url): + """ + Constructor + + @param rule AdBlock rule to add (AdBlockRule) + @param url URL that matched the rule (QUrl) + """ + self.rule = rule + self.url = QUrl(url) + + def __eq__(self, other): + """ + Special method to test equality. + + @param other reference to the other entry (AdBlockedPageEntry) + @return flag indicating equality (boolean) + """ + return self.rule == other.rule and self.url == other.url + + def urlString(self): + """ + Public method to get the URL as a string. + + @return URL as a string (string) + """ + return self.url.toString()
--- a/Helpviewer/AdBlock/AdBlockRule.py Thu Jul 26 18:38:15 2012 +0200 +++ b/Helpviewer/AdBlock/AdBlockRule.py Sat Jul 28 11:23:12 2012 +0200 @@ -9,7 +9,44 @@ import re -from PyQt4.QtCore import Qt, QRegExp, QUrl +from PyQt4.QtCore import Qt, QRegExp, QUrl, qVersion +from PyQt4.QtNetwork import QNetworkRequest + + +# Qt version < 4.8 has an issue; it will wrongly +# count .co.uk (and others) as second-level domains +def toSecondLevelDomain(url): + """ + Module function to get a second level domain from the given URL. + + @param url URL to extract domain from (QUrl) + @return name of second level domain (string) + """ + if qVersion() >= "4.8.0": + topLevelDomain = url.topLevelDomain() + urlHost = url.host() + + if not topLevelDomain or not urlHost: + return "" + + domain = urlHost[:len(urlHost) - len(topLevelDomain)] + if domain.count(".") == 0: + return urlHost + + while domain.count(".") != 0: + domain = domain[domain.find(".") + 1:] + + return domain + topLevelDomain + else: + domain = url.host() + + if domain.count(".") == 0: + return "" + + while domain.count(".") != 1: + domain = domain[domain.find(".") + 1:] + + return domain class AdBlockRule(object): @@ -22,6 +59,28 @@ """ self.__regExp = QRegExp() self.__options = [] + self.__blockedDomains = [] + self.__allowedDomains = [] + + self.__enabled = True + self.__cssRule = False + self.__exception = False + self.__internalDisabled = False + self.__domainRestricted = False + self.__useRegExp = False + self.__useDomainMatch = False + self.__useEndsMatch = False + self.__thirdParty = False + self.__thirdPartyException = False + self.__object = False + self.__objectException = False + self.__subdocument = False + self.__subdocumentException = False + self.__xmlhttprequest = False + self.__xmlhttprequestException = False + self.__document = False + self.__elemhide = False + self.__caseSensitivity = Qt.CaseInsensitive self.setFilter(filter) @@ -40,77 +99,317 @@ @param filter rule filter string (string) """ self.__filter = filter + self.__parseFilter() + + def __parseFilter(self): + """ + Private method to parse the filter pattern. + """ + parsedLine = self.__filter - self.__cssRule = False - self.__enabled = True - self.__exception = False - regExpRule = False + # empty rule or just a comment + if not parsedLine.strip() or parsedLine.startswith("!"): + self.__enabled = False + return - if filter.startswith("!") or not filter.strip(): - self.__enabled = False + # CSS element hiding rule + if "##" in parsedLine: + self.__cssRule = True + pos = parsedLine.find("##") + + # domain restricted rule + if not parsedLine.startswith("##"): + domains = parsedLine[:pos] + self.__parseDomains(domains, ",") + + self.__cssSelector = parsedLine[pos + 2:] + # CSS rule cannot have more options -> stop parsing + return - if "##" in filter: - self.__cssRule = True - - parsedLine = filter + # Exception always starts with @@ if parsedLine.startswith("@@"): self.__exception = True parsedLine = parsedLine[2:] - if parsedLine.startswith("/"): - if parsedLine.endswith("/"): - parsedLine = parsedLine[1:-1] - regExpRule = True + + # Parse all options following '$' character + optionsIndex = parsedLine.find("$") + if optionsIndex >= 0: + options = parsedLine[optionsIndex + 1:].split(",") + + handledOptions = 0 + for option in options: + if option.startswith("domain="): + self.__parseDomains(option[7:], "|") + handledOptions += 1 + elif option == "match-case": + self.__caseSensitivity = Qt.CaseSensitive + handledOptions += 1 + elif option.endswith("third-party"): + self.__thirdParty = True + self.__thirdPartyException = option.startswith("~") + handledOptions += 1 + elif option.endswith("object"): + self.__object = True + self.__objectException = option.startswith("~") + handledOptions += 1 + elif option.endswith("subdocument"): + self.__subdocument = True + self.__subdocumentException = option.startswith("~") + handledOptions += 1 + elif option.endswith("xmlhttprequest"): + self.__xmlhttprequest = True + self.__xmlhttprequestException = option.startswith("~") + handledOptions += 1 + elif option == "document" and self.__exception: + self.__document = True + handledOptions += 1 + elif option == "elemhide" and self.__exception: + self.__elemhide = True + handledOptions += 1 + elif option == "collapse": + # Hiding placeholders of blocked elements + handledOptions += 1 + + # If we don't handle all options, it's safer to just disable this rule + if handledOptions != len(options): + self.__internalDisabled = True + return + + parsedLine = parsedLine[:optionsIndex] + + # Rule is classic regexp + if parsedLine.startswith("/") and parsedLine.endswith("/"): + parsedLine = parsedLine[1:-1] + self.__useRegExp = True + self.__regExp = QRegExp(parsedLine, self.__caseSensitivity, + QRegExp.RegExp) + return - options = parsedLine.find("$") - if options >= 0: - try: - self.__options = parsedLine[options + 1:].split(",") - except IndexError: - self.__options = [] - parsedLine = parsedLine[:options] + # Remove starting / ending wildcards + if parsedLine.startswith("*"): + parsedLine = parsedLine[1:] + if parsedLine.endswith("*"): + parsedLine = parsedLine[:-1] + + # Fast string matching for domain can be used + if parsedLine.startswith("||") and \ + parsedLine.endswith("^") and \ + QRegExp("[/:?=&\\*]").indexIn(parsedLine) == -1: + parsedLine = parsedLine[2:-1] + self.__useDomainMatch = True + self.__matchString = parsedLine + return + + # If rule contains '|' only at the end, string matching can be used + if parsedLine.endswith("|") and \ + QRegExp("[\\^\\*]").indexIn(parsedLine) == -1 and \ + parsedLine.count("|") == 1: + parsedLine = parsedLine[:-1] + self.__useEndsMatch = True + self.__matchString = parsedLine + return - self.setPattern(parsedLine, regExpRule) + # If there is still a wildcard (*) or separator (^) or (|), + # the rule must be modified to comply with QRegExp. + if "*" in parsedLine or "^" in parsedLine or "|" in parsedLine: + pattern = self.__convertPatternToRegExp(parsedLine) + self.__useRegExp = True + self.__regExp = QRegExp(pattern, self.__caseSensitivity, QRegExp.RegExp) + return + + # no regexp required + self.__useRegExp = False + self.__matchString = parsedLine + + def __parseDomains(self, domains, separator): + """ + Private method to parse a string with a domain list. - if "match-case" in self.__options: - self.__regExp.setCaseSensitivity(Qt.CaseSensitive) - self.__options.remove("match-case") + @param domains list of domains (string) + @param separator separator character used by the list (string) + """ + domainsList = domains.split(separator) + + for domain in domainsList: + if not domain: + continue + if domain.startswith("~"): + self.__blockedDomains.append(domain[1:]) + else: + self.__allowedDomains.append(domain) + + self.__domainRestricted = \ + bool(self.__blockedDomains) or bool(self.__allowedDomains) - def networkMatch(self, encodedUrl): + def networkMatch(self, request, domain, encodedUrl): """ Public method to check the rule for a match. + @param request reference to the network request (QNetworkRequest) + @param domain domain name (string) @param encodedUrl string encoded URL to be checked (string) @return flag indicating a match (boolean) """ - if self.__cssRule: + if self.__cssRule or not self.__enabled or self.__internalDisabled: return False + matched = False + + if self.__useRegExp: + matched = self.__regExp.indexIn(encodedUrl) != -1 + elif self.__useDomainMatch: + matched = domain.endswith(self.__matchString) + elif self.__useEndsMatch: + if self.__caseSensitivity == Qt.CaseInsensitive: + matched = encodedUrl.lower().endswith(self.__matchString.lower()) + else: + matched = encodedUrl.endswith(self.__matchString) + else: + if self.__caseSensitivity == Qt.CaseInsensitive: + matched = self.__matchString.lower() in encodedUrl.lower() + else: + matched = self.__matchString in encodedUrl + + if matched: + # check domain restrictions + if self.__domainRestricted and not self.matchDomain(domain): + return False + + # check third-party restrictions + if self.__thirdParty and not self.matchThirdParty(request): + return False + + # check object restrictions + if self.__object and not self.matchObject(request): + return False + + # check subdocument restrictions + if self.__subdocument and not self.matchSubdocument(request): + return False + + # check xmlhttprequest restriction + if self.__xmlhttprequest and not self.matchXmlHttpRequest(request): + return False + + return matched + + def urlMatch(self, url): + """ + Public method to check an URL against the rule. + + @param url URL to check (QUrl) + @return flag indicating a match (boolean) + """ + if not self.__document and not self.__elemhide: + return False + + encodedUrl = bytes(url.toEncoded()).decode() + domain = url.host() + return self.networkMatch(QNetworkRequest(url), domain, encodedUrl) + + def matchDomain(self, domain): + """ + Public method to match a domain. + + @param domain domain name to check (string) + @return flag indicating a match (boolean) + """ if not self.__enabled: return False - matched = self.__regExp.indexIn(encodedUrl) != -1 + if not self.__domainRestricted: + return True - if matched and not len(self.__options) == 0: - # only domain rules are supported - if len(self.__options) == 1: - for option in self.__options: - if option.startswith("domain="): - url = QUrl.fromEncoded(encodedUrl) - host = url.host() - domainOptions = option[7:].split("|") - for domainOption in domainOptions: - negate = domainOption.startswith("~") - if negate: - domainOption = domainOption[1:] - hostMatched = domainOption == host - if hostMatched and not negate: - return True - if not hostMatched and negate: - return True - + if len(self.__blockedDomains) == 0: + for dom in self.__allowedDomains: + if domain.endswith(dom): + return True + elif len(self.__allowedDomains) == 0: + for dom in self.__blockedDomains: + if domain.endswith(dom): + return False + return True + else: + for dom in self.__blockedDomains: + if domain.endswith(dom): + return False + for dom in self.__allowedDomains: + if domain.endswith(dom): + return True + + return False + + def matchThirdParty(self, req): + """ + Public slot to match a third-party rule. + + @param req request object to check (QNetworkRequest) + @return flag indicating a match (boolean) + """ + referer = bytes(req.attribute(QNetworkRequest.User + 200, "")).decode() + if referer == "": return False - return matched + # Third-party matching should be performed on second-level domains + refererHost = toSecondLevelDomain(QUrl(referer)) + host = toSecondLevelDomain(req.url()) + + match = refererHost != host + + if self.__thirdPartyException: + return not match + else: + return match + + def matchObject(self, req): + """ + Public slot to match an object rule. + + @param req request object to check (QNetworkRequest) + @return flag indicating a match (boolean) + """ + match = req.attribute(QNetworkRequest.User + 200) == "object" + + if self.__objectException: + return not match + else: + return match + + def matchSubdocument(self, req): + """ + Public slot to match a sub-document rule. + + @param req request object to check (QNetworkRequest) + @return flag indicating a match (boolean) + """ + originatingFrame = req.originatingObject() + if originatingFrame is None: + return False + + page = originatingFrame.page() + if page is None: + return False + + match = originatingFrame != page.mainFrame() + + if self.__subdocumentException: + return not match + else: + return match + + def matchXmlHttpRequest(self, req): + """ + Public slot to match a XmlHttpRequest rule. + + @param req request object to check (QNetworkRequest) + @return flag indicating a match (boolean) + """ + match = req.rawHeader("X-Request-With") == "XMLHttpRequest" + + if self.__xmlhttprequestException: + return not match + else: + return match def isException(self): """ @@ -156,13 +455,61 @@ """ return self.__cssRule - def regExpPattern(self): + def cssSelector(self): + """ + Public method to get the CSS selector of the rule. + + @return CSS selector (string) + """ + return self.__cssSelector + + def isDocument(self): + """ + Public method to check, if this is a document rule. + + @return flag indicating a document rule (boolean) """ - Public method to get the regexp pattern of the rule. + return self.__document + + def isElementHiding(self): + """ + Public method to check, if this is an element hiding rule. + + @return flag indicating an element hiding rule (boolean) + """ + return self.__elemhide + + def isDomainRestricted(self): + """ + Public method to check, if this rule is restricted by domain. - @return regexp pattern (QRegExp) + @return flag indicating a domain restriction (boolean) + """ + return self.__domainRestricted + + def isComment(self): + """ + Public method to check, if this is a comment. + + @return flag indicating a comment (boolean) + """ + return self.__filter.startswith("!") + + def isSlow(self): """ - return self.__regExp.pattern() + Public method to check, if this is a slow rule. + + @return flag indicating a slow rule (boolean) + """ + return self.__useRegExp + + def isInternalDisabled(self): + """ + Public method to check, if this rule was disabled internally. + + @return flag indicating an internally disabled rule (boolean) + """ + return self.__internalDisabled def __convertPatternToRegExp(self, wildcardPattern): """ @@ -173,30 +520,19 @@ """ pattern = wildcardPattern - pattern = re.sub(r"\*+", "*", pattern) # remove multiple wildcards - pattern = re.sub(r"\^\|$", "^", pattern) # remove anchors following separator placeholder - pattern = re.sub(r"^(\*)", "", pattern) # remove leading wildcards - pattern = re.sub(r"(\*)$", "", pattern) # remove trailing wildcards - pattern = re.sub(r"(\W)", r"\\\1", pattern) # escape special symbols + pattern = re.sub(r"\*+", "*", pattern) # remove multiple wildcards + pattern = re.sub(r"\^\|$", "^", pattern) # remove anchors following separator + # placeholder + pattern = re.sub(r"^(\*)", "", pattern) # remove leading wildcards + pattern = re.sub(r"(\*)$", "", pattern) # remove trailing wildcards + pattern = re.sub(r"(\W)", r"\\\1", pattern) # escape special symbols pattern = re.sub(r"^\\\|\\\|", - r"^[\w\-]+:\/+(?!\/)(?:[^\/]+\.)?", pattern) # process extended anchor at expression start + r"^[\w\-]+:\/+(?!\/)(?:[^\/]+\.)?", pattern) # process extended anchor at + # expression start pattern = re.sub(r"\\\^", - r"(?:[^\w\d\-.%]|$)", pattern) # process separator placeholders - pattern = re.sub(r"^\\\|", "^", pattern) # process anchor at expression start - pattern = re.sub(r"\\\|$", "$", pattern) # process anchor at expression end - pattern = re.sub(r"\\\*", ".*", pattern) # replace wildcards by .* + r"(?:[^\w\d\-.%]|$)", pattern) # process separator placeholders + pattern = re.sub(r"^\\\|", "^", pattern) # process anchor at expression start + pattern = re.sub(r"\\\|$", "$", pattern) # process anchor at expression end + pattern = re.sub(r"\\\*", ".*", pattern) # replace wildcards by .* return pattern - - def setPattern(self, pattern, isRegExp): - """ - Public method to set the rule pattern. - - @param pattern string containing the pattern (string) - @param isRegExp flag indicating a reg exp pattern (boolean) - """ - if isRegExp: - self.__regExp = QRegExp(pattern, Qt.CaseInsensitive, QRegExp.RegExp2) - else: - self.__regExp = QRegExp(self.__convertPatternToRegExp(pattern), - Qt.CaseInsensitive, QRegExp.RegExp2)
--- a/Helpviewer/AdBlock/AdBlockSubscription.py Thu Jul 26 18:38:15 2012 +0200 +++ b/Helpviewer/AdBlock/AdBlockSubscription.py Sat Jul 28 11:23:12 2012 +0200 @@ -57,7 +57,6 @@ self.__networkExceptionRules = [] self.__networkBlockRules = [] - self.__pageRules = [] self.__parseUrl(url) @@ -88,7 +87,7 @@ def url(self): """ - Public method to generate the url for this subscription. + Public method to generate the URL for this subscription. @return AdBlock URL for the subscription (QUrl) """ @@ -324,37 +323,76 @@ for rule in self.__rules: textStream << rule.filter() << "\n" - def pageRules(self): - """ - Public method to get the page rules of the subscription. - - @return list of rule objects (list of AdBlockRule) + def match(self, req, urlDomain, urlString): """ - return self.__pageRules[:] - - def allow(self, urlString): - """ - Public method to check, if the given URL is allowed. + Public method to check the subscription for a matching rule. + @param req reference to the network request (QNetworkRequest) + @param urlDomain domain of the URL (string) + @param urlString URL (string) @return reference to the rule object or None (AdBlockRule) """ for rule in self.__networkExceptionRules: - if rule.networkMatch(urlString): + if rule.networkMatch(req, urlDomain, urlString): + return None + + for rule in self.__networkBlockRules: + if rule.networkMatch(req, urlDomain, urlString): return rule return None - def block(self, urlString): + def adBlockDisabledForUrl(self, url): + """ + Public method to check, if AdBlock is disabled for the given URL. + + @param url URL to check (QUrl) + @return flag indicating disabled state (boolean) """ - Public method to check, if the given URL should be blocked. + for rule in self.__documentRules: + if rule.urlMatch(url): + return True - @return reference to the rule object or None (AdBlockRule) + return False + + def elemHideDisabledForUrl(self, url): + """ + Public method to check, if element hiding is disabled for the given URL. + + @param url URL to check (QUrl) + @return flag indicating disabled state (boolean) """ - for rule in self.__networkBlockRules: - if rule.networkMatch(urlString): - return rule + if self.adBlockDisabledForUrl(url): + return True + + for rule in self.__elemhideRules: + if rule.urlMatch(url): + return True + + return False + + def elementHidingRules(self): + """ + Public method to get the element hiding rules. - return None + @return element hiding rules (string) + """ + return self.__elementHidingRules + + def elementHidingRulesForDomain(self, domain): + """ + Public method to get the element hiding rules for the given domain. + + @param domain domain name (string) + @return element hiding rules (string) + """ + rules = "" + + for rule in self.__domainRestrictedCssRules: + if rule.matchDomain(domain): + rules += rule.cssSelector() + "," + + return rules def allRules(self): """ @@ -402,18 +440,26 @@ """ Private method to populate the various rule caches. """ + self.__networkExceptionRules = [] self.__networkBlockRules = [] - self.__networkExceptionRules = [] - self.__pageRules = [] - if not self.isEnabled(): - return + self.__domainRestrictedCssRules = [] + self.__elementHidingRules = "" + self.__documentRules = [] + self.__elemhideRules = [] for rule in self.__rules: if not rule.isEnabled(): continue if rule.isCSSRule(): - self.__pageRules.append(rule) + if rule.isDomainRestricted(): + self.__domainRestrictedCssRules.append(rule) + else: + self.__elementHidingRules += rule.cssSelector() + "," + elif rule.isDocument(): + self.__documentRules.append(rule) + elif rule.isElementHiding(): + self.__elemhideRules.append(rule) elif rule.isException(): self.__networkExceptionRules.append(rule) else:
--- a/Helpviewer/HelpBrowserWV.py Thu Jul 26 18:38:15 2012 +0200 +++ b/Helpviewer/HelpBrowserWV.py Sat Jul 28 11:23:12 2012 +0200 @@ -45,6 +45,8 @@ from .WebPlugins.WebPluginFactory import WebPluginFactory +from .AdBlock.AdBlockPage import AdBlockedPageEntry + ########################################################################################## @@ -181,6 +183,9 @@ self.__sslConfiguration = None self.__proxy.finished.connect(self.__managerFinished) + + self.__adBlockedEntries = [] + self.loadStarted.connect(self.__loadStarted) def acceptNavigationRequest(self, frame, request, type_): """ @@ -361,6 +366,39 @@ return QWebPage.extension(self, extension, option, output) + def __loadStarted(self): + """ + Private method to handle the loadStarted signal. + """ + self.__adBlockedEntries = [] + + def addAdBlockRule(self, rule, url): + """ + Public slot to add an AdBlock rule to the page. + + @param rule AdBlock rule to add (AdBlockRule) + @param url URL that matched the rule (QUrl) + """ + entry = AdBlockedPageEntry(rule, url) + if entry not in self.__adBlockedEntries: + self.__adBlockedEntries.append(entry) + + def getAdBlockedPageEntries(self): + """ + Public method to get the list of AdBlock page entries. + + @return list of AdBlock page entries (list of AdBlockedPageEntry) + """ + return self.__adBlockedEntries + + def url(self): + """ + Public method to get the URL of the page. + + @return URL of the page (QUrl) + """ + return self.mainFrame().url() + def userAgent(self, resolveEmpty=False): """ Public method to get the global user agent setting. @@ -1671,7 +1709,7 @@ self.zoomOut() if ok: - self.mw.adblockManager().page().applyRulesToPage(self.page()) + self.mw.adblockManager().page().hideBlockedPageEntries(self.page()) self.mw.passwordManager().fill(self.page()) def isLoading(self):
--- a/Helpviewer/WebPlugins/ClickToFlash/ClickToFlash.py Thu Jul 26 18:38:15 2012 +0200 +++ b/Helpviewer/WebPlugins/ClickToFlash/ClickToFlash.py Sat Jul 28 11:23:12 2012 +0200 @@ -10,6 +10,7 @@ from PyQt4.QtCore import pyqtSlot, QUrl, Qt, QByteArray, QTimer from PyQt4.QtGui import QWidget, QMenu, QCursor, QDialog, QLabel, QFormLayout +from PyQt4.QtNetwork import QNetworkRequest from PyQt4.QtWebKit import QWebHitTestResult, QWebElement, QWebView, QWebElementCollection from .Ui_ClickToFlash import Ui_ClickToFlash @@ -44,8 +45,11 @@ manager = Helpviewer.HelpWindow.HelpWindow.adblockManager() if manager.isEnabled(): urlString = bytes(url.toEncoded()).decode() + urlDomain = url.host() for subscription in manager.subscriptions(): - if not subscription.allow(urlString) and subscription.block(urlString): + blockedRule = subscription.match( + QNetworkRequest(url), urlDomain, urlString) + if blockedRule: QTimer.singleShot(200, self.__hideAdBlocked) return @@ -236,7 +240,7 @@ """ self.__findElement() if not self.__element.isNull(): - self.__element.setStyleProperty("visibility", "hidden") + self.__element.setStyleProperty("display", "none") else: self.hide()