Enhance titles - Timvision

Hide titles on Timvision website by clicking on a button

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

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