Feedly Colorful Listview Mod

Feedly Colorful Listview Mod working with Chrome

目前为 2016-11-15 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Feedly Colorful Listview Mod
  3. // @id FeedlyColorfulListviewMod
  4. // @version 0.0.9.20161116
  5. // @description Feedly Colorful Listview Mod working with Chrome
  6. // @namespace https://greasyfork.org/pl/users/66016-marcindabrowski
  7. // @match *://*.feedly.com/*
  8. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
  9. // @require https://greasyfork.org/scripts/23268-waitforkeyelements/code/waitForKeyElements.js?version=147835
  10. // @grant GM_addStyle
  11. // @run-at document-end
  12. // ==/UserScript==
  13. var ColorfulListView = function () {
  14. this.initialize.apply(this, arguments);
  15. };
  16.  
  17. ColorfulListView.prototype = {
  18. initialize:function () {
  19. this.colors = {};
  20. },
  21. makeColor:function (str) {
  22. var h = 0;
  23. for (var i = 0; i < str.length; i++) {
  24. h += str.charCodeAt(i);
  25. }
  26. return {"h":(h%36+1)*10, "s":30 + (h%5+1)*10};
  27. },
  28. color:function (item) {
  29. var itemid = item.id.replace(/^([^=]+).*$/, "$1");
  30. item.setAttribute("data-color", itemid);
  31. if (this.colors[itemid]!==undefined) return null;
  32. this.colors[itemid] = this.makeColor(itemid);
  33. GM_addStyle(
  34. "div[data-color='" + itemid + "'] {background:hsl(" + this.colors[itemid].h + "," + this.colors[itemid].s + "%,80%) !important;}" +
  35. "div[data-color='" + itemid + "']:hover {background:hsl(" + this.colors[itemid].h + "," + this.colors[itemid].s + "%,70%) !important;}"
  36. );
  37. }
  38. };
  39. var colorfulListViewObj = new ColorfulListView();
  40.  
  41. waitForKeyElements (".entry", colorEntry);
  42.  
  43. function colorEntry (jNode) {
  44. colorfulListViewObj.color(jNode[0]);
  45. }