Comments (9)
输入框提示等等功能就不好实现了
from ehsyringe.
这是数据库的json格式吗?
from ehsyringe.
from ehsyringe.
只要你的node能匹配attribute node,其实翻译内容和属性没啥区别
from ehsyringe.
更新了结构
from ehsyringe.
不知道能不能用eval
from ehsyringe.
脚本内可以用eval的
from ehsyringe.
另外 可以使用tabs.executeScript 替代现在用的content_scripts 将数据直接构建到代码里,就可以摆脱对localStorage的依赖还能简化数据同步的逻辑,executeScript是异步的,不知道的可靠性怎么样,如果代码没有在body的dom加载之前注入的话可能会导致翻译失效。
browser.tabs.onUpdated.addListener(async (tabId: number, changeInfo, tab) => {
if(changeInfo['status'] != 'loading') return;
const id = tabId;
console.log('tab onUpdated', tabId, changeInfo, tab);
console.log(tagDatabase.tagList.value);
const code = `
console.log('test');
window.tagData = ${JSON.stringify(tagDatabase.tagList.value, null, 2)};
function test(node) {
if(node.nodeName == '#text' && node.parentNode && node.parentNode.nodeName != 'SCRIPT' )node.textContent = node.textContent + '🐹';
}
const observer = new MutationObserver(mutations => mutations.forEach(mutation =>
mutation.addedNodes.forEach(node1 => {
test(node1);
if (this.documentEnd && node1.childNodes) {
const nodeIterator = document.createNodeIterator(node1);
let node = nodeIterator.nextNode();
while (node) {
test(node);
node = nodeIterator.nextNode();
}
}
})
));
observer.observe(window.document, {
attributes: true,
childList: true,
subtree: true
});
`;
await browser.tabs.executeScript(id, {
code: `
const script = document.createElement('script');
script.innerHTML = \`${code.replace(/`/igm, '\\`').replace(/\\/igm, "\\\\")}\`;
document.head.appendChild(script);
`,
runAt: "document_start",
});
});
from ehsyringe.
是不是可以通过拦截 HTTP 请求来实现翻译。
from ehsyringe.
Related Issues (20)
- 用户同时使用 E-Hentai Downloader 脚本,下载消耗 GP 点的问题 HOT 2
- 添加 创建标签 页面的翻译
- 傲游5 新版本不加载 HOT 1
- 關於功能的疑問 HOT 1
- 双问号语法在via上不支持,考虑加个垫片?
- E-Hentai-Downloader 兼容问题 HOT 2
- 接收悬赏bug HOT 3
- 排行榜界面还没有汉化 HOT 1
- 我的标签界面“移动标签”未能翻译 HOT 1
- 兼容 eHunter
- 能否提供选项,仅翻译一部分 HOT 3
- 归档下载弹窗部分未能翻译
- 翻译新闻页面的站点状态
- 按标签相关画廊数量排序标签匹配结果
- 可以增加一个对标签翻译后增加的小图标的开关吗? HOT 2
- 请问这个aip调用次数超过限制是咋回事 HOT 4
- 可惜与这个脚本冲突 HOT 1
- add english transition HOT 2
- google注入成功之后重新打开浏览器插件就不见了,又要重新注入
- 請問可以同時雙標籤搜尋嗎? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ehsyringe.