Enhance titles - Timvision

Hide titles on Timvision website by clicking on a button

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

  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 03.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. // - [M] remove commented code
  40. // - [L] Integration with IMDb list
  41. //
  42. // Changelog:
  43. // ----------
  44. // 2019.10.03 [1.4] Use classes instead of inline styles
  45. // Optimization: permanently skip invalid entries
  46. // 2019.10.02 [1.3] Simplify code thanks to new EntryList defaults
  47. // 2019.09.30 [1.2] First public version, correct @namespace and other headers
  48. // 2019.09.27 [1.1] Changes due to EntryList (formerly TitleList) refactoring
  49. // 2019.09.21 [1.0] First version. Hiding function and removes useless zooming of title cards on mouseover
  50. // 2019.09.18 [0.1] First test version, private use only
  51. //
  52.  
  53. /* jshint laxbreak: true */
  54. /* global EL: readonly */
  55.  
  56. (function() {
  57. 'use strict';
  58.  
  59. /* BEGIN CONTEXT DEFINITION */
  60.  
  61. var dest = EL.newContext('TIMVision');
  62.  
  63. // other variables
  64. dest.ENTRY_SELECTOR = '.content-item-tile-small';
  65. dest.CLASS_BUTTON = 'EL-TIMVision-HButton';
  66. dest.STYLE_BUTTON = '.' + dest.CLASS_BUTTON + ' {'
  67. + 'position: absolute;'
  68. + 'bottom: 8px;'
  69. + 'left: 8px;'
  70. + 'z-index: 1000;'
  71. + 'width: 30px;'
  72. + 'height: 30px;'
  73. + 'line-height: 30px;'
  74. + 'border: 2px solid white;'
  75. + 'border-radius: 50%;'
  76. + 'background-color: black;'
  77. + 'opacity: 0.5;'
  78. + 'text-align: center;'
  79. + 'vertical-align: middle;'
  80. + 'font-weight: bold;'
  81. + '}';
  82. dest.CLASS_PROCESS = 'EL-TIMVision-Process';
  83. var process_selector = dest.ENTRY_SELECTOR + '.' + dest.CLASS_PROCESS;
  84. dest.STYLE_PROCESS =
  85. process_selector + ' {opacity: 0.15; zoom: .5;} '
  86. + process_selector + ' .' + dest.CLASS_BUTTON + ' {zoom: 2;} '
  87. + process_selector + ' .content-item-tile-title {font-size:26px;}';
  88.  
  89.  
  90. dest.getUser = function() {
  91. var user = document.querySelector('span.username');
  92. if (user) user = user.textContent.trim();
  93. return user;
  94. };
  95.  
  96.  
  97. dest.getPageEntries = function() {
  98. return document.querySelectorAll(this.ENTRY_SELECTOR);
  99. };
  100.  
  101.  
  102. dest.isValidEntry = function(entry) {
  103. return !!(entry.querySelector('a[href^="/detail/"]') || entry.querySelector('a[href^="/series/"]'))
  104. || EL.markInvalid(entry);
  105. };
  106.  
  107.  
  108. dest.modifyEntry = function(entry) {
  109. var d = document.createElement('div');
  110. d.textContent = 'H';
  111. d.title = 'Hide/show this title';
  112. d.className = this.CLASS_BUTTON;
  113. EL.addToggleEventOnClick(d, this.ENTRY_SELECTOR);
  114. entry.querySelector('figure').appendChild(d);
  115.  
  116. // remove useless zooming on mouseover
  117. var parent = entry.parentNode.parentNode.parentNode;
  118. if (!parent.NoMouseOver) {
  119. parent.addEventListener('mouseenter',function(e){e.stopPropagation();},true);
  120. parent.NoMouseOver = true;
  121. }
  122. };
  123.  
  124.  
  125. dest.getIdFromEntry = function(entry) {
  126. var a = entry.querySelector('a[href^="/detail/"]') || entry.querySelector('a[href^="/series/"]');
  127. var id = null;
  128. if (a) {
  129. id = a.href.match(/\/detail\/([0-9]+)-/) || a.href.match(/\/series\/([0-9]+)-/);
  130. if (id && id.length >= 2) id = id[1];
  131. }
  132. if (!id) return null;
  133. return { 'id': id, 'name': a.title };
  134. };
  135.  
  136.  
  137. dest.processItem = function(entry, _I_tt, _I_processingType) {
  138. entry.classList.toggle(this.CLASS_PROCESS, true);
  139. };
  140.  
  141.  
  142. dest.unProcessItem = function(entry, _I_tt, _I_processingType) {
  143. entry.classList.toggle(this.CLASS_PROCESS, false);
  144. };
  145.  
  146. /* END CONTEXT DEFINITION */
  147.  
  148.  
  149.  
  150. //-------- "main" --------
  151. GM_addStyle(dest.STYLE_BUTTON);
  152. GM_addStyle(dest.STYLE_PROCESS);
  153. EL.startup(dest);
  154.  
  155. })();
  156.  
  157. /*
  158. var IMDbSrc = {};
  159. IMDbSrc.name = 'IMDb';
  160.  
  161. IMDbSrc.getUser = function() {
  162. var user;
  163. var account = document.getElementById('consumer_user_nav') ||
  164. document.getElementById('nbpersonalize');
  165. if (account) {
  166. var result = account.getElementsByTagName('strong');
  167. if (!result.length) result = account.getElementsByClassName("navCategory");
  168. if (!result.length) result = account.getElementsByClassName("singleLine");
  169. if (!result.length) result = account.getElementsByTagName("p");
  170. if (result) user = result[0].textContent.trim();
  171. }
  172. return user;
  173. }
  174.  
  175.  
  176. dest.getListsFromEntry = function(tt, entry) {
  177. if (entry.className.indexOf('is-disliked') != -1) return { "localDisliked": true };
  178. }
  179.  
  180. */