Greasy Fork is available in English.

抖音增强

抖音无感知去广告 & 去直播间 & 去购物视频 & 去壁纸视频 & 作品视频列表获取更多数量 & 首页一次性加载更多视频

  1. // ==UserScript==
  2. // @name 抖音增强
  3. // @name:zh-CN 抖音增强
  4. // @name:zh-TW 抖音增強
  5. // @namespace Violentmonkey Scripts
  6. // @match *://www.douyin.com/*
  7. // @version XiaoYing_2024.09.09.2
  8. // @grant GM_info
  9. // @grant GM_getValue
  10. // @grant GM_setValue
  11. // @grant GM_addStyle
  12. // @grant GM_deleteValue
  13. // @grant GM_xmlhttpRequest
  14. // @grant GM_setClipboard
  15. // @grant GM_registerMenuCommand
  16. // @grant GM_unregisterMenuCommand
  17. // @grant GM_getResourceText
  18. // @grant GM_getResourceURL
  19. // @grant GM_openInTab
  20. // @grant unsafeWindow
  21. // @run-at document-start
  22. // @author github.com @XiaoYingYo
  23. // @require https://greasyfork.org/scripts/464929-module-jquery-xiaoying/code/module_jquery_XiaoYing.js
  24. // @require https://greasyfork.org/scripts/464780-global-module/code/global_module.js
  25. // @require https://greasyfork.org/scripts/465643-ajaxhookerlatest/code/ajaxHookerLatest.js
  26. // @description 抖音无感知去广告 & 去直播间 & 去购物视频 & 去壁纸视频 & 作品视频列表获取更多数量 & 首页一次性加载更多视频
  27. // @description:zh-CN 抖音无感知去广告 & 去直播间 & 去购物视频 & 去壁纸视频 & 作品视频列表获取更多数量 & 首页一次性加载更多视频
  28. // @description:zh-TW 抖音無感知去廣告 & 去直播間 & 去購物視頻 & 去壁紙視頻 & 作品視頻列表獲取更多數量 & 首頁一次性加載更多視頻
  29. // ==/UserScript==
  30.  
  31. // eslint-disable-next-line no-undef
  32. ajaxHooker.protect();
  33. var globalVariable = new Map();
  34. globalVariable.set('cacheVideoId', new Map());
  35.  
  36. function handleText(Text) {
  37. let json = null;
  38. try {
  39. json = JSON.parse(Text);
  40. } catch (e) {
  41. console.log(e);
  42. }
  43. if (!json) {
  44. return;
  45. }
  46. let aweme_list = json['aweme_list'];
  47. if (!aweme_list) {
  48. return;
  49. }
  50. let i = 0;
  51. while (i < aweme_list.length) {
  52. let item = aweme_list[i];
  53. let id = item['aweme_id'];
  54. if (globalVariable.get('cacheVideoId').get(id)) {
  55. aweme_list.splice(i, 1);
  56. continue;
  57. }
  58. let cell_room = item['cell_room'];
  59. if (cell_room != null) {
  60. let DouYing_QQ759852125_use_cell_room = localStorage.getItem('DouYing_QQ759852125_use_cell_room') || false;
  61. if (!DouYing_QQ759852125_use_cell_room) {
  62. aweme_list.splice(i, 1);
  63. continue;
  64. }
  65. }
  66. let is_ads = item['is_ads'];
  67. if (is_ads) {
  68. aweme_list.splice(i, 1);
  69. continue;
  70. }
  71. let anchor_info = item['anchor_info'];
  72. if (anchor_info) {
  73. let anchor_info_type = anchor_info['type'];
  74. if (anchor_info_type === 3) {
  75. let DouYing_QQ759852125_use_shop = localStorage.getItem('DouYing_QQ759852125_use_shop') || false;
  76. if (!DouYing_QQ759852125_use_shop) {
  77. aweme_list.splice(i, 1);
  78. continue;
  79. }
  80. }
  81. }
  82. globalVariable.get('cacheVideoId').set(id, 0);
  83. i++;
  84. }
  85. return JSON.stringify(json);
  86. }
  87.  
  88. const ignoreStr = '&ignoreHook=true';
  89.  
  90. function handleResponse(request) {
  91. if (!request) {
  92. return;
  93. }
  94. if (request.url.indexOf(ignoreStr) != -1) {
  95. return;
  96. }
  97. if (request.url.indexOf('/aweme/v1/web/aweme/post/') != -1) {
  98. let count = global_module.GetUrlParm(request.url, 'count');
  99. count = 40;
  100. let newUrl = global_module.SetUrlParm(request.url, 'count', count);
  101. request.url = newUrl;
  102. return;
  103. }
  104. if (request.url.indexOf('/aweme/v1/web/tab/feed/') != -1) {
  105. request.response = (res) => {
  106. let responseText = res.responseText;
  107. if (typeof responseText !== 'string') {
  108. responseText = res.text;
  109. }
  110. res.responseText = new Promise((resolve) => {
  111. res.responseText = handleText(responseText);
  112. res.text = res.responseText;
  113. if (request.type !== 'xhr') {
  114. resolve(res.text);
  115. return;
  116. }
  117. (async function () {
  118. let oldJson = JSON.parse(res.text);
  119. let oldAwemeList = oldJson['aweme_list'];
  120. let Num = localStorage.getItem('DouYing_QQ759852125_getAdditionalVideos') || 2;
  121. Num = parseInt(Num);
  122. if (Num > 10) {
  123. Num = 10;
  124. }
  125. if (Num !== 0) {
  126. let Tasks = [];
  127. for (let i = 0; i < Num; i++) {
  128. Tasks.push(
  129. new Promise((resolve) => {
  130. let Xhr = new XMLHttpRequest();
  131. let url = request.url + ignoreStr;
  132. Xhr.open('GET', url, false);
  133. Xhr.onreadystatechange = function () {
  134. let text = Xhr.responseText;
  135. text = handleText(text);
  136. let json = JSON.parse(text);
  137. let AwemeList = json['aweme_list'];
  138. oldAwemeList.push(...AwemeList);
  139. resolve();
  140. };
  141. Xhr.send();
  142. })
  143. );
  144. }
  145. await Promise.all(Tasks);
  146. let newJson = JSON.stringify(oldJson);
  147. resolve(newJson);
  148. } else {
  149. resolve(res.text);
  150. }
  151. })();
  152. });
  153. };
  154. return;
  155. }
  156. }
  157. // eslint-disable-next-line no-undef
  158. ajaxHooker.hook(handleResponse);