Better Comments for Drive PDF Viewer

Hides every comment in 'comments column' which has no text inside. Makes comments with text inside simpler by hiding author and other data.

  1. // ==UserScript==
  2. // @name Better Comments for Drive PDF Viewer
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.14
  5. // @description Hides every comment in 'comments column' which has no text inside. Makes comments with text inside simpler by hiding author and other data.
  6. // @author Balint Sotanyi
  7. // @match https://drive.google.com/file/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13. document.body.onload = function() {
  14. var style = document.createElement('style'), parent_found = false, comments;
  15. style.innerText = 'div { transition: opacity .8s; }';
  16. document.head.appendChild(style);
  17. var check_interval = setInterval(function() {
  18. var comment_collection = document.getElementsByClassName('dcs-a-dcs-bd dcs-a dcs-a-dcs-u-dcs-v dcs-a-dcs-u-dcs-v-dcs-pf dcs-a-dcs-u-dcs-v-dcs-w-dcs-pf dcs-a-dcs-lg-dcs-ah dcs-a-dcs-lg-dcs-mg');
  19. if (comment_collection !== undefined && comment_collection[0] !== undefined) {
  20. comments = [].slice.call(comment_collection[0].children);
  21. if (comments !== undefined && comments.length > 0) {
  22. clearInterval(check_interval);
  23. comments.forEach(function(c){
  24. try {
  25. var b1 = c.firstElementChild.innerText == "",
  26. b2 = c.firstElementChild.firstElementChild.firstElementChild.firstElementChild.children[1].innerText == "";
  27. } catch (e) { /* omegalul */ }
  28. if (b1 || b2) {
  29. c.style.opacity = '0';
  30. c.style.cursor = 'default';
  31. } else {
  32. var parent = c.firstElementChild.firstElementChild.firstElementChild.firstElementChild;
  33. parent.innerHTML = parent.children[1].innerText;
  34. c.click();
  35. }
  36. });
  37. }
  38. }
  39. }, 1000);
  40. }
  41. })();