Permalink
Browse files

Updated

  • Loading branch information...
1 parent 898a56c commit 4fd41016dfe66c7fe061fe0e44dbc909ec98d72f Fran committed Aug 20, 2011
Showing with 0 additions and 200 deletions.
  1. +0 −18 background.html
  2. BIN icon.png
  3. +0 −19 manifest.json
  4. +0 −163 mark.js
View
@@ -1,18 +0,0 @@
-<html>
- <head>
- <script>
- // Called when the url of a tab changes.
- function checkForValidUrl(tabId, changeInfo, tab) {
- var gr_exp = /google.*\/reader/;
- // If the user is viewing GReader
- if (gr_exp.test(tab.url)) {
- // show the page action.
- chrome.pageAction.show(tabId);
- }
- }
-
- // Listen for any changes to the URL of any tab.
- chrome.tabs.onUpdated.addListener(checkForValidUrl);
- </script>
- </head>
-</html>
View
BIN icon.png
Deleted file not rendered
View
@@ -1,19 +0,0 @@
-{
- "name": "Mark as read",
- "version": "1.0",
- "description": "To mark as read individual items on GReader",
- "background_page": "background.html",
- "page_action": {
- "default_icon": "icon.png",
- "default_title": "Mark As Read for Google Reader",
- },
- "permissions": [
- "tabs", "http://*/*"
- ],
- "content_scripts": [
- {
- "matches": ["http://www.google.es/reader/*","http://www.google.com/reader/*"],
- "js": ["mark.js"]
- }
- ]
-}
View
163 mark.js
@@ -1,163 +0,0 @@
-
-/*
- Mark As Read for Google Reader (Chrome Extension)
- @author franverona (adapted from Greasemonkey script developed by Dmity Rodiontsev)
- @version 1.0
-*/
-
-/*
-
- Version history:
- Agoust 2011 - Extension created and also added "Invert selection" button
-
-*/
-
-var buttonText = "Mark as Read";
-var buttonId = "mark-selected-as-read";
-var articles = new Array();
-
-var buttonTextInv = "Invert Selection";
-var buttonIdInv = "invert-select";
-var articlesInv = new Array();
-
-document.addEventListener("DOMNodeInserted", function(event){
- nodeInserted(event);
-}, true);
-
-function nodeInserted(event) {
- var entries = document.getElementById("entries");
- if (entries && matchClass(entries, "list")) {
- var button = document.getElementById(buttonId);
- if (!button) {
- articles = new Array();
- appendButton();
- }
-
- var element = event.target;
- if (element. className && element.className.match(/entry\s+entry-\d+/) != null) {
- articles.push(element);
-
- var checkbox = document.createElement("input");
- checkbox.type = "checkbox";
- checkbox.className = "mark-selected-as-read-checkbox-class";
- checkbox.style.marginRight = "9px";
- checkbox.style.verticalAlign = "top";
- checkbox.addEventListener("click", function(event) {
- event.stopPropagation();
- }, true);
- var entrySecondary = element.getElementsByClassName("entry-secondary")[0];
- entrySecondary.insertBefore(checkbox, entrySecondary.firstChild);
- }
- }
-}
-
-function appendButton() {
- var viewerTopControlsId = "viewer-top-controls";
- var markAllAsReadId = "mark-all-as-read-split-button";
-
- var divVewerTopControls = document.getElementById(viewerTopControlsId);
- var btnMarkAllAsRead = document.getElementById(markAllAsReadId);
-
- if ((divVewerTopControls != null) && (btnMarkAllAsRead != null)) {
- var button = document.createElement("div");
- button.className = "goog-button goog-button-base unselectable goog-inline-block goog-button-float-left goog-button-tight scour-disabled viewer-buttons";
- button.id = buttonId;
- button.innerHTML = "<div class=\"goog-button-base-outer-box goog-inline-block\">"
- + "<div class=\"goog-button-base-inner-box goog-inline-block\">"
- + "<div class=\"goog-button-base-pos\">"
- + "<div class=\"goog-button-base-top-shadow\">&nbsp;</div>"
- + "<div class=\"goog-button-base-content\">"
- + "<div class=\"goog-button-body\">" + buttonText + "</div>"
- + "</div>"
- + "</div>"
- + "</div>"
- + "</div>";
- button.addEventListener("click", markSelectedAsRead, false);
- divVewerTopControls.insertBefore(button, btnMarkAllAsRead);
-
- var buttonInv = document.createElement("div");
- buttonInv.className = "goog-button goog-button-base unselectable goog-inline-block goog-button-float-left goog-button-tight scour-disabled viewer-buttons";
- buttonInv.id = buttonId;
- buttonInv.innerHTML = "<div class=\"goog-button-base-outer-box goog-inline-block\">"
- + "<div class=\"goog-button-base-inner-box goog-inline-block\">"
- + "<div class=\"goog-button-base-pos\">"
- + "<div class=\"goog-button-base-top-shadow\">&nbsp;</div>"
- + "<div class=\"goog-button-base-content\">"
- + "<div class=\"goog-button-body\">" + buttonTextInv + "</div>"
- + "</div>"
- + "</div>"
- + "</div>"
- + "</div>";
- buttonInv.addEventListener("click", invertSelection, false);
- divVewerTopControls.insertBefore(buttonInv, btnMarkAllAsRead);
- }
-}
-
-function matchClass (element, sClassName) {
- return (sClassName
- && element.className
- && element.className.length
- && element.className.match(new RegExp("(^|\\s+)(" + sClassName +")($|\\s+)")));
-}
-
-function simulateClick(node) {
- var event = node.ownerDocument.createEvent("MouseEvents");
- event.initMouseEvent("click", true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
- node.dispatchEvent(event);
-}
-
-function simulateKeypress(node, keyCode) {
- var event = node.ownerDocument.createEvent("KeyboardEvent");
- event.initKeyboardEvent("keypress", true, true, null, false, false, false, false, keyCode, 0);
- node.dispatchEvent(event);
-}
-
-function simulateRead(node) {
- simulateKeypress(node, 77); //"m" button - mark entry as read.
-}
-
-function simulateCollapse(node) {
- simulateKeypress(node, 79); //"o" button - expand/collapse entry.
-}
-
-function getArticleIcon(article) {
- var divs = article.getElementsByTagName("div");
- for (var i = 0; i < divs.length; i++) {
- var div = divs[i];
- if (matchClass(div, "entry-icons")) return div;
- }
- return null;
-}
-
-function invertSelection(){
- var container = document.getElementById("entries");
- for (var i = 0; i < articles.length; i++) {
- var article = articles[i];
- var checkbox = article.getElementsByTagName("input")[0];
- checkbox.checked = !checkbox.checked;
- }
-}
-
-function markSelectedAsRead() {
- var container = document.getElementById("entries");
- container.style.display = "none";
- for (var i = 0; i < articles.length; i++) {
- var article = articles[i];
- var checkbox = article.getElementsByTagName("input")[0];
- if (checkbox.checked) {
- if (!(matchClass(article, "read"))) {
- var articleIcon = getArticleIcon(article);
- simulateClick(articleIcon);
- if (!(matchClass(article, "read"))) {
- simulateRead(articleIcon);
- }
- if (matchClass(article, "expanded")) {
- simulateClick(articleIcon);
- console.info('match_expanded: '+i);
- }
- }
- checkbox.checked = false;
- }
- }
- container.style.display = "block";
-}

0 comments on commit 4fd4101

Please sign in to comment.