remove-google-click-tracking.patch 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. commit 8d0b67d87462d537af6f7eb0cf445a2f66d5dd5c
  2. Author: csagan5 <32685696+csagan5@users.noreply.github.com>
  3. Date: Sun Oct 15 18:01:18 2017 +0200
  4. Remove click tracking from google search results
  5. diff --git a/third_party/WebKit/Source/core/dom/ContainerNode.cpp b/third_party/WebKit/Source/core/dom/ContainerNode.cpp
  6. index 1bada98..fb15e01 100644
  7. --- a/third_party/WebKit/Source/core/dom/ContainerNode.cpp
  8. +++ b/third_party/WebKit/Source/core/dom/ContainerNode.cpp
  9. @@ -58,6 +58,8 @@
  10. #include "platform/bindings/RuntimeCallStats.h"
  11. #include "platform/bindings/V8PerIsolateData.h"
  12. +#include "base/logging.h"
  13. +
  14. namespace blink {
  15. using namespace HTMLNames;
  16. @@ -1391,6 +1393,26 @@ StaticElementList* ContainerNode::QuerySelectorAll(
  17. return QuerySelectorAll(selectors, ASSERT_NO_EXCEPTION);
  18. }
  19. +// this logic here will cleanup click tracking from hyperlink nodes on search results
  20. +static void applyInsertCustomization(Document *document, Node *c) {
  21. + if (c->getNodeType() != Node::kElementNode)
  22. + return;
  23. + Element *element = ToElement(c);
  24. +
  25. + // filter out non-hyperlink nodes
  26. + if (element->tagName() != "A")
  27. + return;
  28. +
  29. + // determine whether this is a Google search results page
  30. + WTF::String domain = document->GetSecurityOrigin()->Domain();
  31. + size_t pos = domain.Find(".google.");
  32. + if ((pos != WTF::kNotFound) && (domain.length() - pos - 8 < 4)) {
  33. + //LOG(INFO) << "sanitizing Google search results hyperlink, href: " << element->getAttribute("href") << " onmousedown: " << element->getAttribute("onmousedown");
  34. + // remove attribute
  35. + element->removeAttribute("onmousedown");
  36. + }
  37. +}
  38. +
  39. static void DispatchChildInsertionEvents(Node& child) {
  40. if (child.IsInShadowTree())
  41. return;
  42. @@ -1402,6 +1424,10 @@ static void DispatchChildInsertionEvents(Node& child) {
  43. Node* c = &child;
  44. Document* document = &child.GetDocument();
  45. + // csagan5: no extension support in Chrom* for Android? no problem! we add custom code directly here
  46. + if (c->parentNode())
  47. + applyInsertCustomization(document, c);
  48. +
  49. if (c->parentNode() &&
  50. document->HasListenerType(Document::kDOMNodeInsertedListener))
  51. c->DispatchScopedEvent(MutationEvent::Create(