| Index: src/plugin/PluginTabBase.cpp | 
| diff --git a/src/plugin/PluginTabBase.cpp b/src/plugin/PluginTabBase.cpp | 
| index 011c5b5b673e158c18dc40170e361e56b83d3ef0..643b091767c4c4fc5cb6b976d0bda02b0adc679c 100644 | 
| --- a/src/plugin/PluginTabBase.cpp | 
| +++ b/src/plugin/PluginTabBase.cpp | 
| @@ -24,6 +24,7 @@ | 
| #include "IeVersion.h" | 
| #include "../shared/Utils.h" | 
| #include <Mshtmhst.h> | 
| +#include "../shared/Utils.h" | 
|  | 
| CPluginTab::CPluginTab() | 
| : m_isActivated(false) | 
| @@ -174,6 +175,7 @@ void CPluginTab::InjectABP(IWebBrowser2* browser) | 
| DEBUG_ERROR_LOG(0, PLUGIN_ERROR_CREATE_SETTINGS_JAVASCRIPT, PLUGIN_ERROR_CREATE_SETTINGS_JAVASCRIPT_INVOKE, "CPluginTab::InjectABP - Failed to QI document"); | 
| return; | 
| } | 
| + | 
| CComPtr<IHTMLWindow2> pWnd2; | 
| pDoc2->get_parentWindow(&pWnd2); | 
| if (!pWnd2) | 
| @@ -213,6 +215,119 @@ void CPluginTab::InjectABP(IWebBrowser2* browser) | 
| } | 
| } | 
|  | 
| +bool CPluginTab::IsTraverserEnabled() | 
| +{ | 
| +  return !IsCSSInjectionEnabled(); | 
| +} | 
| + | 
| +bool CPluginTab::IsCSSInjectionEnabled() | 
| +{ | 
| +  return IsWindowsVistaOrLater() && AdblockPlus::IE::InstalledMajorVersion() >= 10; | 
| +} | 
| + | 
| +namespace | 
| +{ | 
| +  void InjectABPCSS(IHTMLDocument2& htmlDocument2, const std::vector<std::wstring>& hideFilters) | 
| +  { | 
| +    // pseudocode: styleHtmlElement = htmlDocument2.createElement("style"); | 
| +    ATL::CComQIPtr<IHTMLStyleElement> styleHtmlElement; | 
| +    { | 
| +      ATL::CComPtr<IHTMLElement> stylePureHtmlElement; | 
| +      if (FAILED(htmlDocument2.createElement(ATL::CComBSTR(L"style"), &stylePureHtmlElement))) | 
| +      { | 
| +        DEBUG_GENERAL(L"Cannot create style element"); | 
| +        return; | 
| +      } | 
| +      if (!(styleHtmlElement = stylePureHtmlElement)) | 
| +      { | 
| +        DEBUG_GENERAL(L"Cannot obtain IHTMLStyleElement from IHTMLElement"); | 
| +        return; | 
| +      } | 
| +    } | 
| +    // pseudocode: styleHtmlElement.type = "text/css"; | 
| +    if (FAILED(styleHtmlElement->put_type(ATL::CComBSTR("text/css")))) | 
| +    { | 
| +      DEBUG_GENERAL(L"Cannot set type text/css"); | 
| +      return; | 
| +    } | 
| +    // pseudocode: styleSheet4 = styleHtmlElement.sheet; | 
| +    ATL::CComQIPtr<IHTMLStyleSheet4> styleSheet4; | 
| +    { | 
| +      // IHTMLStyleElement2 is availabe starting from IE9, Vista | 
| +      ATL::CComQIPtr<IHTMLStyleElement2> styleHtmlElement2 = styleHtmlElement; | 
| +      if (!styleHtmlElement2) | 
| +      { | 
| +        DEBUG_GENERAL(L"Cannot obtain IHTMLStyleElement2 from IHTMLStyleElement"); | 
| +        return; | 
| +      } | 
| +      ATL::CComQIPtr<IHTMLStyleSheet> styleSheet; | 
| +      if (FAILED(styleHtmlElement2->get_sheet(&styleSheet)) || !styleSheet) | 
| +      { | 
| +        DEBUG_GENERAL(L"Cannot obtain IHTMLStyleSheet"); | 
| +        return; | 
| +      } | 
| +      // IHTMLStyleSheet4 is availabe starting from IE9, Vista | 
| +      styleSheet4 = styleSheet; | 
| +      if (!styleSheet4) | 
| +      { | 
| +        DEBUG_GENERAL(L"Cannot obtain IHTMLStyleSheet4"); | 
| +        return; | 
| +      } | 
| +    } | 
| +    // pseudocode: for (auto i = 0; i < hideFilters.length; ++i) { | 
| +    // pseudocode:   i = styleSheet4.insertRule(hideFilters + cssValue, i); | 
| +    // pseudocode: } | 
| +    long newIndex = 0; | 
| +    std::wstring cssValue = L"{ display: none !important; }"; | 
| +    for (const auto& selector : hideFilters) | 
| +    { | 
| +      auto cssRule = selector + cssValue; | 
| +      ATL::CComBSTR selector(cssRule.size(), cssRule.c_str()); | 
| +      if (SUCCEEDED(styleSheet4->insertRule(selector, newIndex, &newIndex))) | 
| +      { | 
| +        ++newIndex; | 
| +      } | 
| +      else | 
| +      { | 
| +        DEBUG_GENERAL(L"Cannot add rule for selector " + cssRule); | 
| +      } | 
| +    } | 
| + | 
| +    // pseudocode: htmlDocument2.head.appendChild(styleHtmlElement); | 
| +    { | 
| +      // IHTMLDocument7 is availabe starting from IE9, Vista | 
| +      ATL::CComQIPtr<IHTMLDocument7> htmlDocument7 = &htmlDocument2; | 
| +      if (!htmlDocument7) | 
| +      { | 
| +        DEBUG_GENERAL(L"Cannot obtain IHTMLDocument7 from htmlDocument2"); | 
| +        return; | 
| +      } | 
| +      ATL::CComPtr<IHTMLElement> headHtmlElement; | 
| +      if (FAILED(htmlDocument7->get_head(&headHtmlElement))) | 
| +      { | 
| +        DEBUG_GENERAL(L"Cannot obtain head from pDoc7"); | 
| +        return; | 
| +      } | 
| +      ATL::CComQIPtr<IHTMLDOMNode> headNode = headHtmlElement; | 
| +      if (!headNode) | 
| +      { | 
| +        DEBUG_GENERAL(L"Cannot obtain headNode from headHtmlElement"); | 
| +        return; | 
| +      } | 
| +      ATL::CComQIPtr<IHTMLDOMNode> styleNode = styleHtmlElement; | 
| +      if (!styleNode) | 
| +      { | 
| +        DEBUG_GENERAL(L"Cannot obtain IHTMLDOMNode from stylePureHtmlElement"); | 
| +        return; | 
| +      } | 
| +      if (FAILED(headNode->appendChild(styleNode, nullptr))) | 
| +      { | 
| +        DEBUG_GENERAL(L"Cannot append blocking style"); | 
| +      } | 
| +    } | 
| +  } | 
| +} | 
| + | 
| namespace | 
| { | 
| ATL::CComPtr<IWebBrowser2> GetParent(IWebBrowser2& browser) | 
| @@ -261,11 +376,14 @@ namespace | 
|  | 
| void CPluginTab::OnDownloadComplete(IWebBrowser2* browser) | 
| { | 
| -  CPluginClient* client = CPluginClient::GetInstance(); | 
| -  std::wstring url = GetDocumentUrl(); | 
| -  if (!client->IsWhitelistedUrl(url) && !client->IsElemhideWhitelistedOnDomain(url)) | 
| +  if (IsTraverserEnabled()) | 
| { | 
| -    m_traverser->TraverseDocument(browser, GetDocumentDomain(), GetDocumentUrl()); | 
| +    CPluginClient* client = CPluginClient::GetInstance(); | 
| +    std::wstring url = GetDocumentUrl(); | 
| +    if (!client->IsWhitelistedUrl(url) && !client->IsElemhideWhitelistedOnDomain(url)) | 
| +    { | 
| +      m_traverser->TraverseDocument(browser, GetDocumentDomain(), GetDocumentUrl()); | 
| +    } | 
| } | 
| InjectABP(browser); | 
| } | 
| @@ -300,6 +418,15 @@ void CPluginTab::OnDocumentComplete(IWebBrowser2* browser, const std::wstring& u | 
| return; | 
| } | 
|  | 
| +  if (IsCSSInjectionEnabled() && CPluginSettings::GetInstance()->GetPluginEnabled()) | 
| +  { | 
| +    if (!IsFrameWhiteListed(browser)) | 
| +    { | 
| +      DEBUG_GENERAL(L"Inject CSS into " + url); | 
| +      InjectABPCSS(*pDoc, m_filter.GetHideFilters()); | 
| +    } | 
| +  } | 
| + | 
| CComPtr<IOleObject> pOleObj; | 
| pDocDispatch->QueryInterface(&pOleObj); | 
| if (!pOleObj) | 
|  |