Enhance titles - Timvision

Hide titles on Timvision website by clicking on a button

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

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