Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Unified Diff: components/dom_distiller/core/javascript/extract_features.js

Issue 1047223003: Add integration of the new heuristics (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dd-adaboost-model
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/dom_distiller/core/javascript/extract_features.js
diff --git a/components/dom_distiller/core/javascript/extract_features.js b/components/dom_distiller/core/javascript/extract_features.js
new file mode 100644
index 0000000000000000000000000000000000000000..a454304fbb94ad7ea3a93100136e3680618137b7
--- /dev/null
+++ b/components/dom_distiller/core/javascript/extract_features.js
@@ -0,0 +1,28 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+(function() {
+ function hasOGArticle() {
+ var elems = document.head.querySelectorAll(
+ 'meta[property="og:type"],meta[name="og:type"]');
nyquist 2015/04/01 18:12:20 Nit: Would we need to do anything special if devel
cjhopman 2015/04/01 20:59:29 Yeah, we're not really doing this right, but it's
+ for (var i in elems) {
+ if (elems[i].content && elems[i].content.toUpperCase() == 'ARTICLE') {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ var body = document.body;
+ return {
nyquist 2015/04/01 18:12:20 return as stringified to help out our iOS friends?
cjhopman 2015/04/01 20:59:29 Done.
+ 'opengraph': hasOGArticle(),
+ 'url': document.location.href,
+ 'numElements': body.querySelectorAll('*').length,
+ 'numAnchors': body.querySelectorAll('a').length,
+ 'numForms': body.querySelectorAll('form').length,
+ 'innerText': body.innerText,
+ 'textContent': body.textContent,
nyquist 2015/04/01 18:12:20 It would be amazing if we at some point would get
cjhopman 2015/04/01 20:59:29 Yeah, it would be nice.
+ 'innerHTML': body.innerHTML,
+ }
+})()

Powered by Google App Engine
This is Rietveld 408576698