Skip to content
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

介绍原理 #4

Open
14790897 opened this issue Dec 7, 2023 · 4 comments
Open

介绍原理 #4

14790897 opened this issue Dec 7, 2023 · 4 comments

Comments

@14790897
Copy link
Owner

14790897 commented Dec 7, 2023

主要逻辑在src\background\index.ts中

切换功能由handleTabChange实现,原理其实很简单就是在用户切换标签页的时候,先保存旧的页面的 cookies,然后清除旧的页面的cookies,再然后加载新的页面的cookies(如果新的标签页没有已经保存的cookiea就跳过)

至于如何操作cookie,Chrome浏览器提供了对应的api如chrome.cookies.getAll({ domain: rootDomain })await chrome.cookies.set(fixedCookie)

@14790897
Copy link
Owner Author

14790897 commented Dec 7, 2023

我也是刚编程一年的新手,代码写的一般,请多多包涵

@TheKonka
Copy link

TheKonka commented Dec 7, 2023

学习了,大佬

@TheKonka
Copy link

TheKonka commented Dec 8, 2023

这样切换标签页到新的页面,如果旧的页面还有请求一直在进行的话,请求是不是会失败?

@14790897
Copy link
Owner Author

14790897 commented Dec 8, 2023

是的,我在kaggle上试过,当你运行kaggle的机器学习程序后切换标签页,他有可能将分配的运行资源回收,并问你are you stiil here,而在正常操作下只有很长时间没有在此页面操作,才会将你的资源回收

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants