🏠 Home 

Greasy Fork is available in English.

Calm Quora's annoying red notification dots

The red notifications dots on Quora are annoying, so let's make them grey. Also hide the popups, separate adverts from content, don't keep opening new tabs, and add some whitespace for readability.


安装此脚本?
  1. // ==UserScript==
  2. // @name Calm Quora's annoying red notification dots
  3. // @namespace joeytwiddle
  4. // @version 1.2.0
  5. // @license MIT
  6. // @description The red notifications dots on Quora are annoying, so let's make them grey. Also hide the popups, separate adverts from content, don't keep opening new tabs, and add some whitespace for readability.
  7. // @author joeytwiddle
  8. // @match https://*.quora.com/*
  9. // @grant GM_addStyle
  10. // @run-at document-start
  11. // ==/UserScript==
  12. var makeRedNotificationsGrey = true;
  13. var makeTheHeaderGray = false;
  14. var hidePopups = true;
  15. // Not removing adverts or promotions, but at least don't make them look like answers. 🙄
  16. var deemphasiseAds = true;
  17. var distinguishPromotedAnswers = true;
  18. var openLinksInThisWindow = true;
  19. // I find the answers on Quora sort of blur into each other
  20. // To address that, this increases the spacing between them
  21. var increaseSeparationOfAnswers1 = true;
  22. // And this indents each answer, but leaves the user's profile picture sticking out
  23. var increaseSeparationOfAnswers2 = true;
  24. function afterPageLoad (callback) {
  25. //setTimeout(callback, 400);
  26. document.addEventListener('DOMContentLoaded', () => setTimeout(callback, 4000));
  27. }
  28. if (makeRedNotificationsGrey) {
  29. // Make the red notification dots grey instead
  30. //GM_addStyle('.SiteHeaderBadge, .WriteNavbadge, .red_badge, .ui_unread_badge_with_count, .site_header_badge_wrapper .ui_count_badge { background: #ddd !important; background-color: #ddd !important; color: #444 !important; opacity: 0.5; }');
  31. // This was causing the circle to turn into a rounded square: transform: scale(0.8);
  32. // Although if we wanted, we could apply it to the parent: .site_header_badge_wrapper { transform: scale(0.8); }
  33. //GM_addStyle('.qu-bg--red { filter: saturate(0%); }');
  34. //GM_addStyle('.q-absolute.qu-top--tiny .qu-bg--red { background-color: #ccc; }');
  35. GM_addStyle('.qu-zIndex--header .qu-bg--red { background-color: #ccc; }');
  36. }
  37. // Just make the whole damn header grey!
  38. // As requested by Keeni: https://greasyfork.org/en/forum/discussion/37380/x
  39. if (makeTheHeaderGray) {
  40. //GM_addStyle('.SiteHeader, .questions_to_answer_icon { filter: saturate(0%); }');
  41. //GM_addStyle('.q-fixed.qu-top--0.qu-fullX { filter: saturate(0%); }');
  42. GM_addStyle('.qu-zIndex--header { filter: saturate(0%); }');
  43. }
  44. if (hidePopups) {
  45. GM_addStyle('.Growl { display: none !important; }');
  46. }
  47. if (deemphasiseAds) {
  48. afterPageLoad(function () {
  49. // Quora's advertisements appear visually a lot like the answers, so it is easy to read an advert and get confused because it's talking about a completely tangential topic.
  50. // For some reason, I decided not to remove the adverts completely, but to de-emphasise them and differentiate them.
  51. // The padding is needed so that the text doesn't appear to close to the edge of the red box.
  52. // A hint of Quora red:
  53. //var cssForAdverts = { backgroundColor: 'hsl(3, 25%, 90%)', opacity: 0.3, padding: '1em' };
  54. // Just a light grey
  55. var cssForAdverts = { backgroundColor: '#f2f2f2', opacity: 0.5, padding: '1em', border: '1px solid #bbb' };
  56. // No background, just de-emphasise. The padding is not strictly necessary but it can help to differentiate.
  57. //var cssForAdverts = { opacity: 0.3, padding: '1em' };
  58. //var cssForAdverts = { opacity: 0.1, padding: '0em' };
  59. /*
  60. //jQuery('.advertiser_endpoint').closest('.outer_content_box').css(cssForAdverts)
  61. // jQuery isn't always loaded at this point of time, so let's use DOM instead.
  62. Array.from(document.querySelectorAll('.advertiser_endpoint')).map(ad => ad.closest('.outer_content_box')).forEach(elem => elem && Object.assign(elem.style, cssForAdverts));
  63. // On the "Home" feed page
  64. // '.PromptsList'
  65. Array.from(document.querySelectorAll('.AdStory')).forEach(elem => elem && Object.assign(elem.style, cssForAdverts));
  66. Array.from(document.querySelectorAll('.dismissed_msg_wrapper')).map(elem => (elem.parentNode || {}).parentNode).forEach(elem => elem && Object.assign(elem.style, cssForAdverts));
  67. */
  68. // 2020
  69. //.q-text.qu-mb--tiny.qu-bold.qu-color--gray_dark_dim.qu-passColorToLinks.TitleText___StyledText-sc-1hpb63h-0.kfJcxX
  70. //.q-text.qu-mb--tiny.qu-bold -> closest('.spacing_log_question_page_ad') oh
  71. //Array.from(document.querySelectorAll('.spacing_log_question_page_ad')).forEach(elem => elem && Object.assign(elem.style, cssForAdverts));
  72. // 2021, promoted questions
  73. Array.from(document.querySelectorAll('.q-box.qu-borderBottom'))
  74. .filter(elem => elem.textContent.startsWith('Sponsored by '))
  75. .forEach(elem => Object.assign(elem.style, cssForAdverts));
  76. });
  77. }
  78. if (distinguishPromotedAnswers) {
  79. afterPageLoad(function () {
  80. // These are sometimes more relevant to the question than standard adverts, so let's not deemphasise them quite so much
  81. //GM_addStyle('.promoted_answer_wrapper { background-color: #f4f4f4; opacity: 0.7; padding: 1em; border: 1px solid #bbb; }');
  82. var cssForPromotions = { backgroundColor: '#f4f4f4', opacity: 0.7, padding: '1em', border: '1px solid #bbb' };
  83. Array.from(document.querySelectorAll('.q-box.qu-borderBottom'))
  84. .filter(elem => elem.textContent.startsWith('Promoted by '))
  85. .forEach(elem => Object.assign(elem.style, cssForPromotions));
  86. });
  87. }
  88. // Beautify avatars
  89. GM_addStyle('.feed_item_answer_user .user { font-weight: 600; }');
  90. GM_addStyle('.NameCredential, .IdentityCredential, .UserCredential { font-style: italic; font-size: 85%; }');
  91. if (increaseSeparationOfAnswers1) {
  92. // Instead of answers cramped together with horizontal rules separating them, put some nice big whitespace between each answer
  93. //GM_addStyle('.NewGridQuestionPage .AnswerBase { border-top: none; padding: 50px 0px 50px; }');
  94. // Or keep the lines close to the top of each answer
  95. GM_addStyle('.NewGridQuestionPage .AnswerBase { margin: 40px 0px; border-top: none !important; }');
  96. // This gives the same spacing to the adverts
  97. GM_addStyle('.content_area { margin: 40px 0px; }');
  98. }
  99. if (increaseSeparationOfAnswers2) {
  100. GM_addStyle('.Answer { padding-left: 45px; }');
  101. GM_addStyle('.ContentHeader { margin-left: -47px; }');
  102. }
  103. if (openLinksInThisWindow) {
  104. afterPageLoad(function () {
  105. document.body.addEventListener('click', function (evt) {
  106. var link = evt.target.closest('a');
  107. if (link && link.getAttribute('target') === '_blank') {
  108. link.setAttribute('target', '');
  109. }
  110. });
  111. });
  112. }