V2EX troilus 的所有回复 第 1 页 / 共 27 页
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX    troilus    全部回复第 1 页 / 共 27 页
回复总数  522
1  2  3  4  5  6  7  8  9  10 ... 27  
领了个 40-20
44 天前
回复了 jinreal 创建的主题 Chrome 维基百科中英文页面切换插件
有没有可能用扩展太“重”了,一个油猴脚本:
```
// ==UserScript==
// @name 维基百科跨语言跳转助手(改进版)
// @namespace http://tampermonkey.net/
// @version 1.1
// @description 在维基百科页面显示对应语言版本的链接,从语言接栏获取准确 URL
// @author ChatGPT
// @match https://zh.wikipedia.org/*
// @match https://en.wikipedia.org/*
// @match https://*.wikipedia.org/*
// @icon https://www.wikipedia.org/static/favicon/wikipedia.ico
// @grant none
// @license MIT
// ==/UserScript==

(function() {
'use strict';

// 添加自定义样式
const style = document.createElement('style');
style.textCOntent= `
.wp-crosslang-container {
display: inline-block;
margin-left: 12px;
vertical-align: middle;
}

.wp-crosslang-btn {
background: #f8f9fa;
border: 1px solid #a2a9b1;
border-radius: 2px;
padding: 3px 8px;
font-size: 12px;
color: #0645ad;
cursor: pointer;
transition: all 0.2s ease;
text-decoration: none;
display: inline-block;
}

.wp-crosslang-btn:hover {
background: #fff;
border-color: #0645ad;
color: #0645ad;
text-decoration: none;
}

.wp-crosslang-btn:active {
background: #f0f0f0;
}

.wp-crosslang-loading {
opacity: 0.7;
cursor: wait;
}

@media screen and (max-width: 768px) {
.wp-crosslang-container {
display: block;
margin-left: 0;
margin-top: 8px;
}
}
`;
document.head.appendChild(style);

// 获取对应语言的链接
function getLanguageLink(targetLang) {
// 在侧边栏语言列表中找到目标语言链接
const langList = document.querySelector('#p-lang .wbc-editpage, #p-lang .wb-langlinks-link');
if (langList) {
const langLinks = document.querySelectorAll('#p-lang li a');
for (const link of langLinks) {
const href = link.getAttribute('href');
const lang = link.getAttribute('lang') || link.getAttribute('hreflang') || '';
const text = link.textContent.trim();

if (lang === targetLang ||
(targetLang === 'en' && text === 'English') ||
(targetLang === 'zh' && text === '中文')) {
return href;
}
}
}

// 尝试在页面底部的语言链接中找到
const interwikiLinks = document.querySelectorAll('.interlanguage-link a');
for (const link of interwikiLinks) {
const lang = link.getAttribute('lang') || link.getAttribute('hreflang') || '';
const text = link.textContent.trim();
const href = link.getAttribute('href');

if (lang === targetLang ||
(targetLang === 'en' && text === 'English') ||
(targetLang === 'zh' && text === '中文')) {
return href;
}
}

return null;
}

// 获取当前语言和目标语言
function getLanguages() {
const hostname = window.location.hostname;

if (hostname.includes('zh.') || hostname.includes('.zh.')) {
return { current: 'zh', target: 'en', targetName: 'English' };
} else if (hostname.includes('en.') || hostname.includes('.en.')) {
return { current: 'en', target: 'zh', targetName: '中文' };
}

// 默认情况
return { current: 'en', target: 'zh', targetName: '中文' };
}

// 创建跳转按钮
function createJumpButton(href, targetName) {
const cOntainer= document.createElement('div');
container.className = 'wp-crosslang-container';

const button = document.createElement('a');
button.className = 'wp-crosslang-btn';
button.href = href;
button.target = '_blank';
button.rel = 'noopener noreferrer';
button.textCOntent= targetName;

// 添加点击事件
button.addEventListener('click', function(e) {
console.log(`跳转到${targetName}版维基百科`);
});

container.appendChild(button);
return container;
}

// 创建加载中的按钮
function createLoadingButton(targetName) {
const cOntainer= document.createElement('div');
container.className = 'wp-crosslang-container';

const button = document.createElement('span');
button.className = 'wp-crosslang-btn wp-crosslang-loading';
button.textCOntent= `加载${targetName}...`;

container.appendChild(button);
return container;
}

// 主函数
function init() {
// 获取语言信息
const { target, targetName } = getLanguages();

// 获取标题元素
const titleElement = document.querySelector('#firstHeading, .mw-first-heading, .firstHeading, h1');
if (!titleElement) {
console.log('无法找到标题元素');
return;
}

// 先创建加载中的按钮
const loadingButton = createLoadingButton(targetName);
titleElement.appendChild(loadingButton);

// 尝试获取语言链接
const langLink = getLanguageLink(target);

if (langLink) {
// 移除加载按钮,添加实际链接按钮
titleElement.removeChild(loadingButton);
const button = createJumpButton(langLink, targetName);
titleElement.appendChild(button);
} else {
// 没有找到对应语言链接,更新按钮状态
loadingButton.querySelector('span').textCOntent= `无${targetName}版本`;
loadingButton.querySelector('span').classList.remove('wp-crosslang-loading');
}
}

// 页面加载完成后执行
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', init);
} else {
init();
}
})();
```
44 天前
回复了 wanmyj 创建的主题 生活 候补了一张邓紫棋的票,搜了下她的身世,果然五世家业才有的黄四郎
维护阶级利益而已
44 天前
回复了 abbb 创建的主题 问与答 如何拦截凤凰网底部广告
自己 F12 调调布局,调正常了后, 把你调的方法让 ai 写个油猴
44 天前
回复了 tog 创建的主题 iOS 苹果系统天气预报是不是不准的?
windy 和 bing 的效果要好点
Nokia 6030
@RavelloH nice !
@RavelloH 就每天一条就行啦,当天的新闻
可以支持 rss 订阅吗
@pkoukk #62 好多是蹭流量的。。
跑外卖,
官方的云听
在网络测去看设备联网记录
试试 pc 上把路由表改下,tun 的时候 0.0.0.0 全走 tun 那个网关
手机和电脑组网后直接连个代理软件起的 socks 、https 代理之类的呗
98 天前
回复了 xz410236056 创建的主题 分享发现 原来 bing 搜索能换东西
邀请码还是说下呗
希望能够比较中国城市大小
看看 wewerss 什么问题, 目前我的跑了几个月了没问题
删除的时候不要清除数据
1  2  3  4  5  6  7  8  9  10 ... 27  
关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2268 人在线   最高记录 6679       Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 36ms UTC 15:58 PVG 23:58 LAX 08:58 JFK 11:58
Do have faith in what you're doing.
ubao snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86