Feedly Hide Read Items When Done

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

当前为 2017-08-07 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Feedly Hide Read Items When Done
  3. // @version 1.1.5.1
  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.5.1 - Bugfix for last update.
  12. // 1.1.5 - Updated element to check for due to Feedly's August 2017 update removing the magic string.
  13. // 1.1.4 - Updated magic string from "No unread articles" to "No unread stories".
  14. // 1.1.3 - Reference one fewer element from DOM in hopes of having less DOM-based bugs.
  15. // 1.1.2 - Fix for Feedly's update to DOM.
  16. // 1.1.1 - Fix issue where the page refreshes while you're still reading the last article.
  17. // 1.1 - Fix for updated version of feedly.
  18. // 1.0 - Initial Release.
  19. (function() {
  20. console.debug("[FHRIWD] - running");
  21. var tweakXHR = function () {
  22. console.debug("[FHRIWD] Customizing XMLHttpRequest.");
  23. try {
  24. XMLHttpRequest.prototype.open_old = XMLHttpRequest.prototype.open;
  25. XMLHttpRequest.prototype.open = function (method, url, async, user, pass) {
  26. this.addEventListener("readystatechange", function() {
  27. try {
  28. var unreadCountSpan = document.querySelector("div.mark-as-read-button-group.button.secondary button span");
  29. if (unreadCountSpan == null || Number(unreadCountSpan.textContent.trim()) == 0) {
  30. if (document.querySelector("div.inlineFrame.read.selected") != null) { //Don't hide when still reading the last article.
  31. console.info("[FHRIWD] Still reading last item, doing nothing.");
  32. } else {
  33. console.info("[FHRIWD] All items read - hiding timeline.");
  34. document.querySelector("#feedlyPageFX > div > div:nth-child(2)").innerHTML = "<p>No Unread Items</p>";
  35. }
  36. }
  37. } catch (e) {
  38. console.error("[FHRIWD] " + e.message);
  39. }
  40. }, false);
  41. this.open_old.call(this, method, url, async, user, pass);
  42. };
  43. } catch (e) {
  44. console.error("[FHRIWD] " + e.message);
  45. }
  46. console.debug("[FHRIWD] Finished customizing XMLHttpRequest.");
  47. };
  48. //Inject the script into the page.
  49. var script = document.createElement('script');
  50. script.setAttribute('type','application/javascript');
  51. script.textContent = '(' + tweakXHR + ')();';
  52. document.body.appendChild(script); //run the script
  53. document.body.removeChild(script); //cleanup
  54. console.debug("[FHRIWD] - complete");
  55. }());