// ==UserScript== // @name ccw-detail-nologin // @version 20260718-1329 // @description CCW共创世界不登录访问作品详情。 // @author bddjr // @namespace https://bddjr.com/ // @license Unlicense // @homepage https://github.com/bddjr/ccw-detail-nologin // @supportURL https://github.com/bddjr/ccw-detail-nologin/issues // @match https://www.ccw.site/ // @match https://www.ccw.site/detail/* // @match https://www.ccw.site/embed // @match https://www.ccw.site/gamejam/* // @match https://www.ccw.site/mmo // @match https://www.ccw.site/player/* // @match https://www.ccw.site/PlayerWithInRouter/* // @grant none // @run-at document-start // @icon https://m.ccw.site/community/images/logo-ccw.png // @downloadURL https://raw.githubusercontent.com/bddjr/ccw-detail-nologin/refs/heads/main/ccw-detail-nologin.user.js // @updateURL https://raw.githubusercontent.com/bddjr/ccw-detail-nologin/refs/heads/main/ccw-detail-nologin.user.js // ==/UserScript== // https://github.com/bddjr/ccw-detail-nologin const userScriptName = "ccw-detail-nologin" const { log } = console /** * @param {string} propertyKey 劫持的属性名称。 * @param {string} propertyValueStr 在 vendor~main 里。 * @param {string} originalArg0Str 参数0在 main 里。 * @param {Function} outArg0Func 把参数0篡改成自己的函数。 */ function hijackObjectPrototypeSetter(propertyKey, propertyValueStr, originalArg0Str, outArg0Func) { /** @type {{ [key: string]: any }} */ const target = Object.prototype /** @type {PropertyDescriptor} */ const propertyDescriptor = { /** * @this {any} * @param {any} value * @returns {void} */ set(value) { delete target[propertyKey]; if (typeof value == 'function' && value == propertyValueStr) { /** @param {...any} a */ this[propertyKey] = function (...a) { if (typeof a[0] == 'function' && a[0] == originalArg0Str) { a[0] = outArg0Func } return value.apply(this, a) } // 任务完成,不再劫持这个属性。 log(`[${userScriptName}] 已劫持 ${propertyKey}`) return } this[propertyKey] = value Object.defineProperty(target, propertyKey, propertyDescriptor) }, configurable: true, } Object.defineProperty(target, propertyKey, propertyDescriptor) } // 第一关:未完成作品加载时弹出“请登录后游玩”,并且舞台显示“此作品禁止未登录用户游玩” hijackObjectPrototypeSetter( "useMemo", 'function(e,t){return O().useMemo(e,t)}', 'function(){return(null==i?void 0:i.includes("CCWMMO"))&&!N||n&&!N}', () => false ) // 第二关:作品加载完成后,点击“开始运行”的时候要求登录 hijackObjectPrototypeSetter( "useCallback", 'function(e,t){return O().useCallback(e,t)}', 'function(){var t=function(e){var t=e.infoCompleted;return e.studentOid?c:t?r:N}({infoCompleted:M,studentOid:u});return t===c||(t===N||(e(Object(n.b)({reloadAfterLoginSuccess:!0})),Object(a.k)(a.c.MODAL)),!1)}', () => true )