// ==UserScript== // @name 抖音网页版优化 // @description 抖音网页版推荐、直播优化,网页全屏,全黑,自动按浏览器窗口调整大小 // @namespace https://space.bilibili.com/482343 // @author 古海沉舟 // @license 古海沉舟 // @version 1.14.13 // @match https://www.douyin.com/* // @include https://*.douyin.com/* // @require https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/3.6.0/jquery.min.js // @require https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/howler/2.2.3/howler.min.js // @run-at document-end // @grant GM_setValue // @grant GM_getValue // @grant GM_addValueChangeListener // @noframes // @downloadURL none // ==/UserScript== // 全局变量 var zz = ['', '', '', '', '', '', '', '']; var zzb = ['', '', '', '', '', '', '', '']; var lastindex = 0, livecount = 0, h = '', h0 = '', sortdone = 0, wt = 0, wt2 = 0, ct = 0, bs = null, liveheight = null; var islog = 1, isred = 1, ispayhide = 0, ismirror = 0, deletecount = 0, haspagefullscreen = 0; var zzx = GM_getValue('zz', []); var zzy = GM_getValue('zzb', []); var colors = { reset: '\x1b[0m', red: '\x1b[31m', green: '\x1b[32m', yellow: '\x1b[33m', blue: '\x1b[34m', magenta: '\x1b[35m', cyan: '\x1b[36m', white: '\x1b[37m' }; // 函数定义 function toObj(arr) { var obj = {}; for (var temp in arr) { obj[arr[temp]] = true; } return obj; } function toArr(obj) { var arr = []; for (var temp in obj) { arr.push(temp); } return arr; } function together(a, b) { for (var temp = 0; temp < b.length; temp++) { if (b[temp] && b[temp] !== 'null' && b[temp].length < 40) { a.push(b[temp].toLowerCase()); } } } function getUniq(arr) { return toArr(toObj(arr)); } function cc(color, args) { var total = ''; for (var i = 1; i < arguments.length; i++) { total += arguments[i]; } console.log(colors[color] + total + colors.reset); } function keydown(event) { if (event.keyCode === 109 || event.keyCode === 189) { // 按 - 或小键盘 - pagefullscreen(); } else if (event.keyCode === 187 || event.keyCode === 106) { // 按 = 或小键盘 * payhide(); } else if (event.keyCode === 111 || event.keyCode === 191) { // 按 / 或小键盘 / videomirror(); } else if (event.keyCode === 105) { // 按小键盘 9 isred = 1 - isred; } } function livesort() { var livea = '#douyin-right-container > div.parent-route-container.route-scroll-container.LhqxgEn_ > div.tR7Ulcih > div > div.e3ffUpdr > ul.HK1P5LMm.NpyoaYHH'; var lul = '#douyin-right-container > div.jRsgdw_0 > div > div.Cts4MhxF > ul:first-of-type'; if ($(lul).length < 1) { lul = '#douyin-right-container > div.parent-route-container.route-scroll-container.h5AVrOfS > div.jRsgdw_0 > div > div.Cts4MhxF > ul.QTHs3MFv.zzJBL64E'; } if (deletecount < 1) { $(livea + ' > li, #douyin-right-container > div.parent-route-container.route-scroll-container > div > div > div > ul > li').each(function() { if ($(this).text().indexOf('个作品未看') > -1) { deletecount++; cc('blue', '删除作品未看', $(this)[0]); $(this).hide(); } }); $('#douyin-right-container > div.parent-route-container.route-scroll-container > div > div > div > div').each(function() { if ($(this).text().indexOf('精选关注人') > -1) { deletecount++; cc('blue', '精选关注人', $(this)[0]); $(this).hide(); } }); $('#douyin-right-container > div.jRsgdw_0 > div > div.Cts4MhxF').children(':not(ul:first-of-type)').each(function() { deletecount++; cc('blue', '删除非直播', $(this)[0]); $(this).hide(); }); } if ($(lul).html() == h || sortdone == 1) { return; } livecount = $(lul + ' > li').length; if (livecount > 0) { cc('blue', '当前直播个数:', livecount); var h1 = '', h2 = '', h3 = '', h4 = '', ho = ''; $(lul + ' > li:not([fi])').each(function() { $(this).attr('fi', '1'); var find = 0; var fl = $(this).find('a').attr('href') || $(this).children('div.frvzAIi8').children('a').attr('href'); if (!fl) return; var oh = $(this)[0].outerHTML; for (var x = 0; x < zz.length; x++) { if (zz[x] && fl.indexOf(zz[x]) > -1) { find = 1; if (oh.indexOf('福袋') > 0 || oh.indexOf('红包') > 0) { h1 = oh+h1; } else { h1 += oh; } break; } } if (find) return; for (x = 0; x < zzb.length; x++) { if (zzb[x] && fl.indexOf(zzb[x]) > -1) { find = 1; if (oh.indexOf('福袋') > 0 || oh.indexOf('红包') > 0) { h2 = oh+h2; } else { h2 += oh; } break; } } if (find) return; if (oh.indexOf('福袋') > 0) { h3 += oh; } else if (oh.indexOf('红包') > 0) { h4 += oh; } else { ho += oh; } }); h = h1 + h2 + h3 + h4 + ho; if (h) { cc('blue', '重新排序后'); cc('blue', h); sortdone = 1; cc('blue', '排序次数:', sortdone); //$(lul).html(h); // 创建新容器 var newContainer = $('