Empty Comment Hider for Drive PDF Viewer

Hides every comment in 'comments column' which has no text inside.

当前为 2020-05-14 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Empty Comment Hider for Drive PDF Viewer
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.12
  5. // @description Hides every comment in 'comments column' which has no text inside.
  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. }
  32. });
  33. }
  34. }
  35. }, 1000);
  36. }
  37. })();