1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // The possible log levels.
12 // Defines the current log level. Values other than "none" are for debugging
13 // only and should at no point be checked in.
14 var currentLogLevel = logLevels.none;
16 function containsFeed(doc) {
17 debugMsg(logLevels.info, "containsFeed called");
19 // Find all the RSS link elements.
20 var result = doc.evaluate(
21 '//*[local-name()="rss" or local-name()="feed" or local-name()="RDF"]',
25 debugMsg(logLevels.info, "exiting: document.evaluate returned no results");
26 return false; // This is probably overly defensive, but whatever.
29 var node = result.iterateNext();
32 debugMsg(logLevels.info, "returning: iterateNext() returned no nodes");
33 return false; // No RSS tags were found.
36 // The feed for arab dash jokes dot net, for example, contains
37 // a feed that is a child of the body tag so we continue only if the
38 // node contains no parent or if the parent is the body tag.
39 if (node.parentElement && node.parentElement.tagName != "BODY") {
40 debugMsg(logLevels.info, "exiting: parentElement that's not BODY");
44 debugMsg(logLevels.info, "Found feed");
49 function debugMsg(loglevel, text) {
50 if (loglevel <= currentLogLevel) {
51 console.log("RSS Subscription extension: " + text);