-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix uninstall #129
Fix uninstall #129
Conversation
zhbyak
commented
Apr 19, 2024
- 解决background和content加载不同步导致的通信异常问题
- 首次安装的时候,删除浏览器url中的xfans_token字段(会触发再次自动登录)
- 首次安装的时候,进行一次logout
@@ -12,7 +12,6 @@ const manifest: ManifestV3Export = { | |||
{ | |||
matches: ['https://twitter.com/*'], | |||
js: ['src/content/index.tsx'], | |||
run_at: 'document_end', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个你不是要解决 interval handle resize 的问题的么,这里删了,那边又行了?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个document_end没有解决问题,实际还是过早,还是在load的事件里面处理
@@ -58,3 +58,21 @@ async function withProxyStore(children: ReactElement, proxyStore: Store): Promis | |||
return <Provider store={proxyStore}>{children}</Provider>; | |||
}); | |||
} | |||
|
|||
// 监听来自 Background 脚本的消息 | |||
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如何确保这里收到的就是来自 background 的消息
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嗯 目前场景没有其他业务发送消息。
我加了一个消息下判断做了筛选
src/content/index.tsx
Outdated
const url = new URL(window.location.href); // 获取当前URL | ||
url.searchParams.delete(XFANS_TOKEN); // 删除指定的查询参数 | ||
// 使用 history.replaceState 更新 URL | ||
window.history.replaceState(null, '', url.toString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
需要注释为什么这么做
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
// 获取当前活动标签页 | ||
const activeTab = tabs[0]; | ||
|
||
if (activeTab) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果我登录后关闭 twitter,然后再卸载插件呢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
没问题 因为这个代码是插件加载成功之后,给background发消息,background做的回应。所以这个场景下twitter页面一定存在