Enhance titles - Timvision

Hide titles on Timvision website by clicking on a button

当前为 2019-10-10 提交的版本,查看 最新版本

  1. // Enhance titles - Timvision
  2. // Hide titles on Timvision website by clicking on a button
  3. //
  4. // https://greasyfork.org/scripts/390632-enhance-titles-timvision
  5. // Copyright (C) 2019, Guido Villa
  6. //
  7. // For instructions, see https://greasyfork.org/help/installing-user-scripts
  8. //
  9. // --------------------------------------------------------------------
  10. //
  11. // ==UserScript==
  12. // @name Enhance titles - Timvision
  13. // @description Hide titles on Timvision website by clicking on a button
  14. // @version 1.4
  15. // @author guidovilla
  16. // @date 10.10.2019
  17. // @copyright 2019, Guido Villa (https://greasyfork.org/users/373199-guido-villa)
  18. // @license GPL-3.0-or-later
  19. // @homepageURL https://greasyfork.org/scripts/390632-enhance-titles-timvision
  20. // @supportURL https://gitlab.com/gv-browser/userscripts/issues
  21. // @contributionURL https://tinyurl.com/gv-donate-3a
  22. //
  23. // @namespace https://greasyfork.org/users/373199-guido-villa
  24. //
  25. // @match https://www.timvision.it/*
  26. //
  27. // @require https://greasyfork.org/scripts/390248-entrylist/code/EntryList.js
  28. // @grant GM_getValue
  29. // @grant GM_setValue
  30. // @grant GM_listValues
  31. // @grant GM_addStyle
  32. // ==/UserScript==
  33. //
  34. // --------------------------------------------------------------------
  35. //
  36. // To-do (priority: [H]igh, [M]edium, [L]ow):
  37. // - [M] check if title id is really unique for a title or if multiple ids are possible
  38. // - [M] add some @exclude
  39. // - [L] Integration with IMDb list
  40. //
  41. // Changelog:
  42. // ----------
  43. // 2019.10.10 [1.4] Use classes instead of inline styles, some code cleanup
  44. // Optimization: permanently skip invalid entries
  45. // 2019.10.02 [1.3] Simplify code thanks to new EntryList defaults
  46. // 2019.09.30 [1.2] First public version, correct @namespace and other headers
  47. // 2019.09.27 [1.1] Changes due to EntryList (formerly TitleList) refactoring
  48. // 2019.09.21 [1.0] First version. Hiding function and removes useless zooming of title cards on mouseover
  49. // 2019.09.18 [0.1] First test version, private use only
  50. //
  51.  
  52. /* jshint laxbreak: true */
  53. /* global EL: readonly */
  54.  
  55. (function() {
  56. 'use strict';
  57.  
  58. /* BEGIN CONTEXT DEFINITION */
  59.  
  60. var timvision = EL.newContext('TIMVision');
  61.  
  62. // other variables
  63. timvision.ENTRY_SELECTOR = '.content-item-tile-small';
  64. timvision.CLASS_BUTTON = 'EL-TIMVision-HButton';
  65. timvision.STYLE_BUTTON = '.' + timvision.CLASS_BUTTON + ' {'
  66. + 'position: absolute;'
  67. + 'bottom: 8px;'
  68. + 'left: 8px;'
  69. + 'z-index: 1000;'
  70. + 'width: 30px;'
  71. + 'height: 30px;'
  72. + 'line-height: 30px;'
  73. + 'border: 2px solid white;'
  74. + 'border-radius: 50%;'
  75. + 'background-color: black;'
  76. + 'opacity: 0.5;'
  77. + 'text-align: center;'
  78. + 'vertical-align: middle;'
  79. + 'font-weight: bold;'
  80. + '}';
  81. timvision.CLASS_PROCESS = 'EL-TIMVision-Process';
  82. var process_selector = timvision.ENTRY_SELECTOR + '.' + timvision.CLASS_PROCESS;
  83. timvision.STYLE_PROCESS =
  84. process_selector + ' {opacity: 0.15; zoom: .5;} '
  85. + process_selector + ' .' + timvision.CLASS_BUTTON + ' {zoom: 2;} '
  86. + process_selector + ' .content-item-tile-title {font-size:26px;}';
  87.  
  88.  
  89. timvision.getUser = function() {
  90. var user = document.querySelector('span.username');
  91. if (user) user = user.textContent.trim();
  92. return user;
  93. };
  94.  
  95.  
  96. timvision.getPageEntries = function() {
  97. return document.querySelectorAll(this.ENTRY_SELECTOR);
  98. };
  99.  
  100.  
  101. timvision.isValidEntry = function(entry) {
  102. return !!(entry.querySelector('a[href^="/detail/"]') || entry.querySelector('a[href^="/series/"]'))
  103. || EL.markInvalid(entry);
  104. };
  105.  
  106.  
  107. timvision.modifyEntry = function(entry) {
  108. var d = document.createElement('div');
  109. d.textContent = 'H';
  110. d.title = 'Hide/show this title';
  111. d.className = this.CLASS_BUTTON;
  112. EL.addToggleEventOnClick(d, this.ENTRY_SELECTOR);
  113. entry.querySelector('figure').appendChild(d);
  114.  
  115. // remove useless zooming on mouseover
  116. var parent = entry.parentNode.parentNode.parentNode;
  117. if (!parent.NoMouseOver) {
  118. parent.addEventListener('mouseenter',function(e){e.stopPropagation();},true);
  119. parent.NoMouseOver = true;
  120. }
  121. };
  122.  
  123.  
  124. timvision.getIdFromEntry = function(entry) {
  125. var a = ( entry.querySelector('a[href^="/detail/"]') || entry.querySelector('a[href^="/series/"]') );
  126. var id = null;
  127. if (a) {
  128. id = ( a.href.match(/\/detail\/([0-9]+)-/) || a.href.match(/\/series\/([0-9]+)-/) );
  129. if (id && id.length >= 2) id = id[1];
  130. }
  131. if (!id) return null;
  132. return { 'id': id, 'name': a.title };
  133. };
  134.  
  135.  
  136. timvision.processItem = function(entry, _I_tt, _I_processingType) {
  137. entry.classList.toggle(this.CLASS_PROCESS, true);
  138. };
  139.  
  140.  
  141. timvision.unProcessItem = function(entry, _I_tt, _I_processingType) {
  142. entry.classList.toggle(this.CLASS_PROCESS, false);
  143. };
  144.  
  145. /* END CONTEXT DEFINITION */
  146.  
  147.  
  148.  
  149. //-------- "main" --------
  150. GM_addStyle(timvision.STYLE_BUTTON);
  151. GM_addStyle(timvision.STYLE_PROCESS);
  152. EL.startup(timvision);
  153.  
  154. })();