Tumblr hide without blocking

Hides conversations in the messages dialog with specific users, and stops those users from appearing as suggested recipients of posts when you click share.

  1. // ==UserScript==
  2. // @name Tumblr hide without blocking
  3. // @namespace https://github.com/holyspiritomb
  4. // @match https://www.tumblr.com/*
  5. // @grant GM_getValue
  6. // @grant GM_setValue
  7. // @grant GM_addStyle
  8. // @grant GM_listValues
  9. // @version 0.0.5
  10. // @author holyspiritomb
  11. // @run-at document-end
  12. // @require https://code.jquery.com/jquery-latest.min.js
  13. // @require https://greasyfork.org/scripts/446257-waitforkeyelements-utility-function/code/waitForKeyElements%20utility%20function.js?version=1059316
  14. // @inject-into page
  15. // @icon https://www.google.com/s2/favicons?domain=tumblr.com
  16. // @description Hides conversations in the messages dialog with specific users, and stops those users from appearing as suggested recipients of posts when you click share.
  17. // ==/UserScript==
  18.  
  19. let valueArrayList = GM_listValues();
  20.  
  21. function inList(itemToTest, someList) {
  22. let itemIndex = someList.indexOf(itemToTest);
  23. if (itemIndex == -1) {
  24. return false;
  25. } else {
  26. return true;
  27. }
  28. }
  29.  
  30. function annotateConversations() {
  31. $('button[aria-label=Conversation] div.pTvJc').each(function() {
  32. let friendName = $(this)[0].innerText;
  33. let conversation = $(this).closest('button');
  34. let convClasses = Array.from(conversation[0].classList);
  35. if (convClasses.indexOf(friendName) == -1) {
  36. conversation.addClass(friendName);
  37. console.log(`added ${friendName} as class to a conversation`);
  38. }
  39. });
  40. }
  41.  
  42. if (valueArrayList) {
  43.  
  44. console.log("get value of key hiddenRecipients");
  45. let hiddenRecipients = Array.from(GM_getValue("hiddenShareRecipients"));
  46.  
  47. if (hiddenRecipients[0] != "hiddenfriend") {
  48. console.log("processing array of hidden recipients in share popup");
  49. for (friend of hiddenRecipients) {
  50. console.log(`adding css to hide ${friend} from share popup`);
  51. GM_addStyle(`button[aria-label="Select ${friend}"]{display:none;}`);
  52. };
  53. } else {
  54. console.log("no one to hide in the share popup");
  55. }
  56.  
  57. let hiddenConversations = Array.from(GM_getValue("hiddenConversations"));
  58.  
  59. if (hiddenConversations[0] != "hiddenfriend") {
  60. for (hiddenConversationPartner of hiddenConversations) {
  61. //console.log(`adding css rule to hide ${hiddenConversationPartner} in conversations`);
  62. GM_addStyle(`button[aria-label=Conversation].${hiddenConversationPartner}{display:none;}`);
  63. };
  64. let currentPage = document.location.href;
  65. if (currentPage == "https://www.tumblr.com/messaging") {
  66. waitForKeyElements("button[aria-label='Conversation'] div.pTvJc", function() {
  67. annotateConversations();
  68. }, false, 1000, 20);
  69. } else {
  70. waitForKeyElements("button[aria-label='Conversation'] div.pTvJc", function() {
  71. annotateConversations();
  72. }, false, 300, -1);
  73. }
  74. } else {
  75. console.log("no conversations to hide");
  76. }
  77.  
  78. } else {
  79. console.log("No values stored. making default keys now");
  80. GM_setValue("hiddenShareRecipients", ["hiddenfriend"]);
  81. GM_setValue("hiddenConversations", ["hiddenfriend"]);
  82. }