功能:
快速跳转
提高空间的可阅读性
感谢:
一开始想的是从网页链接里提取uid,后面听 @user_login 的改成了从空间左上角获取,脚本容易写了很多
已知不足:
”记录“页面也会被包括进去,会多显示一点白色打开” 隐私设置,您不能访问当前内容“的网页时会获取不到uid,所有跳转功能就失效了
- // ==UserScript==
- // @name 开门!查房!
- // @version 1.3
- // @author M
- // @match https://www.gamemale.com/space*
- // @match https://www.gamemale.com/home.php?mod=space&uid*
- // @match https://www.gamemale.com/blog*
- // @grant GM_registerMenuCommand
- // ==/UserScript==
- (function() {
- 'use strict';
- var style = document.createElement('style');
- style.innerHTML = "#ct { background-image: none !important; background-color: #fff !important; }";
- style.innerHTML += "#ct * { color: #000 !important; }";
- document.head.appendChild(style);
- })();
- (function() {
- 'use strict';
- const menuAll = [
- ['menu_home', '首页', 'index&view=me&from=space'],
- ['menu_dynamic', '动态', 'home&view=me&from=space'],
- ['menu_record', '记录', 'doing&view=me&from=space'],
- ['menu_journal', '日志', 'blog&view=me&from=space'],
- ['menu_theme', '主题', 'thread&view=me&from=space'],
- ['menu_message', '留言板', 'wall&view=me&from=space'],
- ['menu_profile', '个人资料', 'profile']
- ];
- function createMenu(menu, uid) {
- GM_registerMenuCommand(menu[1], () => {
- window.location.href = `https://www.gamemale.com/home.php?mod=space&uid=${uid}&do=${menu[2]}`;
- });
- }
- function init() {
- const domainUrl = document.getElementById('domainurl');
- const urlParam = domainUrl ? domainUrl.href.match(/\?(\d+)/) : null;
- const uid = urlParam ? urlParam[1] : '';
- const menuContainer = document.createElement('div');
- menuContainer.id = 'menu-container';
- menuAll.forEach(menu => {
- createMenu(menu, uid);
- });
- document.body.appendChild(menuContainer);
- }
- init();
- })();
复制代码
|