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

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

Issue 464973002: JavaScript that returns whether or not a page is an article (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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/is_readable.js
diff --git a/components/dom_distiller/core/javascript/is_readable.js b/components/dom_distiller/core/javascript/is_readable.js
new file mode 100644
index 0000000000000000000000000000000000000000..4edbd21a34012f14d8d4875b0bcacc1c278dca72
--- /dev/null
+++ b/components/dom_distiller/core/javascript/is_readable.js
@@ -0,0 +1,17 @@
+function() {
Yaron 2014/08/12 18:55:05 Rename something like is_distillable_trigger
Yaron 2014/08/12 18:55:05 Add copyright
smaslo 2014/08/12 20:42:23 Done.
smaslo 2014/08/12 20:42:23 I renamed the class. If I give the method a name,
+ var elems = document.querySelectorAll(
+ 'meta[property="og:type"],meta[name=\\"og:type\\"]');
+ for (var i in elems) {
+ if (elems[i].content && elems[i].content.toUpperCase() == 'ARTICLE') {
+ return true;
+ }
+ }
+ var elems = document.querySelectorAll(
+ '*[itemtype="http://schema.org/Article"]');
+ for (var i in elems) {
+ if (elems[i].itemscope) {
+ return true;
+ }
+ }
+ return false;
+}

Powered by Google App Engine
This is Rietveld 408576698