您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
xxx
当前为
// ==UserScript== // @name xx 圈按时间排序 // @namespace http://tampermonkey.net/ // @version 0.1 // @license WTFPL // @description xxx // @author Yxxx // @match https://ee.bytedance.net/malaita/pc/* // @icon https://ee.bytedance.net/malaita/static/img/malaita.png // @grant GM_registerMenuCommand // @grant GM_unregisterMenuCommand // @grant GM_getValue // @grant GM_setValue // @grant unsafeWindow // ==/UserScript== (function () { const MENU_ALL = [ ['menu_time_order', '帖子按时间排序', true, () => { switchMenuCommand('menu_time_order'); alert('请手动刷新页面以生效.'); }], ['menu_filter_new_bytedancer', '过滤新人报道 TODO', true, () => { switchMenuCommand('menu_filter_new_bytedancer') }], ['menu_filter_anonymous', '过滤匿名 TODO', true, () => { switchMenuCommand('menu_filter_anonymous') }], ['menu_post_blackword_list', '过滤词列表 (逗号分隔) TODO', '', () => { }], ['menu_debug_menu', 'DEBUG MENU', 0, () => { console.log(MENU_VALUE, REGISITED_MENU_ID) }] ]; const MENU_VALUE = {}; const REGISITED_MENU_ID = []; function registerMenuCommand() { if (REGISITED_MENU_ID.length >= MENU_ALL.length) { REGISITED_MENU_ID.forEach(id => GM_unregisterMenuCommand(id)); REGISITED_MENU_ID.length = 0; } MENU_ALL.forEach(([key, name, defaultValue, handler]) => { let v = MENU_VALUE[key] ?? GM_getValue(key); if (v == null){ GM_setValue(key, defaultValue); v = defaultValue; }; MENU_VALUE[key] = v; const menuId = GM_registerMenuCommand(`${v === true ? '✅ ' : v === false ? '❌ ': ''}${name}`, handler); REGISITED_MENU_ID.push(menuId); }); } function switchMenuCommand(key) { const currentValue = MENU_VALUE[key]; GM_setValue(key, !currentValue); MENU_VALUE[key] = !currentValue; registerMenuCommand(); } const originFetch = fetch; console.log(originFetch) window.unsafeWindow.fetch = (url, options) => { return originFetch(url, options).then(async (response) => { console.log('hack: ', url, options) if(MENU_VALUE.menu_time_order && url === '/malaita/v2/user/settings/'){ console.log('hit'); const responseClone = response.clone(); let res = await responseClone.json(); res.feed_type = 1; console.log(res); const responseNew = new Response(JSON.stringify(res), response); return responseNew; }else{ return response; } }); }; registerMenuCommand(); })();