Feedly Hide Read Items When Done

Hide the read items list when you have finished reading unread items.

目前為 2014-06-11 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Feedly Hide Read Items When Done
  3. // @version 1.1.3
  4. // @namespace geekrunner
  5. // @include *cloud.feedly.com/*
  6. // @include *feedly.com/*
  7. // @description Hide the read items list when you have finished reading unread items.
  8. // ==/UserScript==
  9.  
  10. // VERSION HISTORY
  11. // 1.1.3 - Reference one fewer element from DOM in hopes of having less DOM-based bugs.
  12. // 1.1.2 - Fix for Feedly's update to DOM.
  13. // 1.1.1 - Fix issue where the page refreshes while you're still reading the last article.
  14. // 1.1 - Fix for updated version of feedly.
  15. // 1.0 - Initial Release.
  16. (function() {
  17. console.debug("[FHRIWD] - running");
  18. var tweakXHR = function () {
  19. console.debug("[FHRIWD] Customizing XMLHttpRequest.");
  20. try {
  21. XMLHttpRequest.prototype.open_old = XMLHttpRequest.prototype.open;
  22. XMLHttpRequest.prototype.open = function (method, url, async, user, pass) {
  23. this.addEventListener("readystatechange", function() {
  24. try {
  25. var unreadCountSpan = document.querySelector("#feedlyTitleBar span.categoryUnreadCountHint");
  26. if (unreadCountSpan == null) {
  27. console.info("[FHRIWD] Could not find unread count message - doing nothing.");
  28. } else if (unreadCountSpan.textContent.trim()=="No unread articles") {
  29. if (document.getElementsByClassName("selectedEntry").length == 0) { //Don't hide when still reading the last article.
  30. console.info("[FHRIWD] All items read - hiding timeline.");
  31. document.getElementById("timeline").style.display = "none";
  32. document.getElementById("noUpdatesMessage").style.display = "block";
  33. }
  34. }
  35. } catch (e) {
  36. console.error("[FHRIWD] " + e.message);
  37. }
  38. }, false);
  39. this.open_old.call(this, method, url, async, user, pass);
  40. };
  41. } catch (e) {
  42. console.error("[FHRIWD] " + e.message);
  43. }
  44. console.debug("[FHRIWD] Finished customizing XMLHttpRequest.");
  45. };
  46. //Inject the script into the page.
  47. var script = document.createElement('script');
  48. script.setAttribute('type','application/javascript');
  49. script.textContent = '(' + tweakXHR + ')();';
  50. document.body.appendChild(script); //run the script
  51. document.body.removeChild(script); //cleanup
  52. console.debug("[FHRIWD] - complete");
  53. }());