Skip to content

Commit

Permalink
Added option to ignore store id when importing/exporting cookies via …
Browse files Browse the repository at this point in the history
…json
  • Loading branch information
null93 committed Nov 13, 2024
1 parent 35a5f23 commit 7898213
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 23 deletions.
46 changes: 34 additions & 12 deletions src/components/Options.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import SearchIcon from "@material-ui/icons/Search"
import SecurityIcon from "@material-ui/icons/Security"
import BlockIcon from "@material-ui/icons/Block"
import PaletteIcon from "@material-ui/icons/Palette"
import SettingsSuggestIcon from "@material-ui/icons/SettingsSuggest"
import ExitToAppIcon from "@material-ui/icons/ExitToApp"
import SpecialThanksIcon from "@material-ui/icons/Favorite"
import Toolbar from "@material-ui/core/Toolbar"
Expand Down Expand Up @@ -260,6 +261,10 @@ class Options extends React.Component {
<ListItemIcon>{<PaletteIcon/>}</ListItemIcon>
<ListItemText primary={i18n.translate ("appearance")} />
</ListItem>
<ListItem button onClick={() => window.location = "#functionality"} >
<ListItemIcon>{<SettingsSuggestIcon/>}</ListItemIcon>
<ListItemText primary={i18n.translate ("functionality")} />
</ListItem>
<ListItem button onClick={() => window.location = "#blocked-cookies"} >
<ListItemIcon>{<BlockIcon/>}</ListItemIcon>
<ListItemText primary={i18n.translate ("blockedCookies")} />
Expand Down Expand Up @@ -315,6 +320,34 @@ class Options extends React.Component {
</AccordionSummary>
</Accordion>
</div>
<Typography id="functionality" className={classes.section} variant="h6" >{i18n.translate ("functionality")}</Typography>
<Typography className={classes.paragraph} color="textSecondary" >
{i18n.translate ("functionalityDescription")}
</Typography>
<div>
<Accordion elevation={2} expanded={false} >
<AccordionSummary classes={{ content: classes.summary }} >
<Typography>{i18n.translate ("updateProtectedCookiesValue")}</Typography>
<Switch
color="primary"
size="small"
checked={storage.data.updateProtectedValue}
onChange={e => storage.set ( "updateProtectedValue", e.target.checked )}
/>
</AccordionSummary>
</Accordion>
<Accordion elevation={2} expanded={false} >
<AccordionSummary classes={{ content: classes.summary }} >
<Typography>{i18n.translate ("ignoreStoreId")}</Typography>
<Switch
color="primary"
size="small"
checked={storage.data.ignoreStoreId}
onChange={e => storage.set ( "ignoreStoreId", e.target.checked )}
/>
</AccordionSummary>
</Accordion>
</div>
<Typography id="appearance" className={classes.section} variant="h6" >{i18n.translate ("appearance")}</Typography>
<Typography className={classes.paragraph} color="textSecondary" >
{i18n.translate ("appearanceDescription")}
Expand Down Expand Up @@ -384,17 +417,6 @@ class Options extends React.Component {
/>
</AccordionSummary>
</Accordion>
<Accordion elevation={2} expanded={false} >
<AccordionSummary classes={{ content: classes.summary }} >
<Typography>{i18n.translate ("updateProtectedCookiesValue")}</Typography>
<Switch
color="primary"
size="small"
checked={storage.data.updateProtectedValue}
onChange={e => storage.set ( "updateProtectedValue", e.target.checked )}
/>
</AccordionSummary>
</Accordion>
<Accordion elevation={2} expanded={false} >
<AccordionSummary classes={{ content: `${classes.summary} ${classes.noMargin}` }} >
<Typography>{i18n.translate ("expirationTimeFormat")}</Typography>
Expand Down Expand Up @@ -436,7 +458,7 @@ class Options extends React.Component {
</AccordionSummary>
</Accordion>
</div>
<Typography id="blocked-cookies" className={classes.section} variant="h6" >{i18n.translate ("")}</Typography>
<Typography id="blocked-cookies" className={classes.section} variant="h6" >{i18n.translate ("blockedCookies")}</Typography>
<Typography className={classes.paragraph} color="textSecondary" >
{i18n.translate ("blockedCookiesDescription")}
</Typography>
Expand Down
22 changes: 21 additions & 1 deletion src/contexts/CookiesContext.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,22 @@ class CookiesProvider extends React.Component {

getJson ( cookie ) {
const { found } = this.state
return JSON.stringify ( cookie ? cookie : found, null, "\t" )
const { storage } = this.props
const { ignoreStoreId } = storage.data
var data = cookie ? cookie : found
if ( ignoreStoreId ) {
if ( Array.isArray ( data ) ) {
data = data.map ( cookie => {
const { storeId, ...rest } = cookie
return rest
})
}
else {
const { storeId, ...rest } = data
data = rest
}
}
return JSON.stringify ( data, null, "\t" )
}

getNetscape ( cookie ) {
Expand Down Expand Up @@ -178,6 +193,8 @@ class CookiesProvider extends React.Component {
}

import ( updateCount ) {
const { storage } = this.props
const { ignoreStoreId } = storage.data
return new Promise ( ( resolve, reject ) => {
const chooser = document.createElement ("input")
chooser.type = "file"
Expand All @@ -200,6 +217,9 @@ class CookiesProvider extends React.Component {
failed: [],
}
return Promise.each ( data, cookie => {
if ( ignoreStoreId ) {
cookie.storeId = undefined
}
return utils.set ( cookie )
.then ( () => {
results.current++
Expand Down
1 change: 1 addition & 0 deletions src/data/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = {
expirationFormat: "humanized",
sortType: "expirationDate",
sortDirection: "ascending",
ignoreStoreId: false,
// Lists
protect: {},
block: {},
Expand Down
11 changes: 10 additions & 1 deletion src/data/locales/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module.exports = {
"message": "These settings are stored locally and are not synced across browsers. Case sensitivity applies to both regular and regexp search."
},
"appearanceDescription": {
"message": "Unfortunately Chrome extensions cannot detect if your system is using a Dark theme. Thankfully, there is still a dark mode that you can set manually!"
"message": "Adjust visual settings to personalize your browsing experience, including theme and display options."
},
"blockedCookiesDescription": {
"message": "When a cookie is blocked, the name, domain, and path is saved and is used to block future cookies from being created. All three properties must match exactly for a cookie to be blocked."
Expand Down Expand Up @@ -386,4 +386,13 @@ module.exports = {
"exportCookie": {
"message": "Export Cookie"
},
"functionality": {
"message": "Functionality"
},
"functionalityDescription": {
"message": "Manage how cookies are processed and interacted with, offering precise control over cookie handling behaviors."
},
"ignoreStoreId": {
"message": "Ignore Store ID"
},
}
11 changes: 10 additions & 1 deletion src/data/locales/ru.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module.exports = {
"message": "Эти настройки хранятся локально и не синхронизируются между браузерами. Чувствительность к регистру применяется как к обычному поиску, так и к поиску по регулярному выражению."
},
"appearanceDescription": {
"message": "К сожалению, расширения Chrome не могут определить, использует ли ваша система темную тему. К счастью, все еще есть темный режим, который вы можете установить вручную!"
"message": "Настройте визуальные параметры, чтобы персонализировать ваш опыт просмотра, включая темы и параметры отображения."
},
"blockedCookiesDescription": {
"message": "Когда файл Печенье заблокирован, имя, домен и путь сохраняются и используются для блокировки создания файлов Печенье в будущем. Все три свойства должны точно совпадать, чтобы файл Печенье был заблокирован."
Expand Down Expand Up @@ -386,4 +386,13 @@ module.exports = {
"exportCookie": {
"message": "Экспортировать куки"
},
"functionality": {
"message": "Функциональность"
},
"functionalityDescription": {
"message": "Управляйте тем, как обрабатываются и взаимодействуют с cookies, предлагая точный контроль над поведением обработки cookies."
},
"ignoreStoreId": {
"message": "Игнорировать Store ID"
},
}
11 changes: 10 additions & 1 deletion src/data/locales/zh.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module.exports = {
"message": "这些设置存储在本地,不会在浏览器之间同步。区分大小写适用于常规搜索和正则表达式搜索。"
},
"appearanceDescription": {
"message": "不幸的是,Chrome 扩展程序无法检测到您的系统是否使用深色主题。值得庆幸的是,您仍然可以手动设置深色模式!"
"message": "调整视觉设置以个性化您的浏览体验,包括主题和显示选项。"
},
"blockedCookiesDescription": {
"message": "cookie 被阻止后,其名称、域和路径将被保存,用于阻止今后创建的cookies。这三个属性必须完全匹配,cookie 才能被阻止。"
Expand Down Expand Up @@ -386,4 +386,13 @@ module.exports = {
"exportCookie": {
"message": "导出Cookie"
},
"functionality": {
"message": "功能"
},
"functionalityDescription": {
"message": "管理如何处理和交互 cookies,提供对 cookies 处理行为的精确控制。"
},
"ignoreStoreId": {
"message": "忽略 Store ID"
},
}
26 changes: 19 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,20 @@
dependencies:
regenerator-runtime "^0.13.11"

"@babel/runtime@^7.0.0", "@babel/runtime@^7.3.1", "@babel/runtime@^7.4.4", "@babel/runtime@^7.5.5", "@babel/runtime@^7.7.2", "@babel/runtime@^7.8.3", "@babel/runtime@^7.8.7":
"@babel/runtime@^7.0.0", "@babel/runtime@^7.3.1", "@babel/runtime@^7.5.5", "@babel/runtime@^7.7.2", "@babel/runtime@^7.8.3", "@babel/runtime@^7.8.7":
version "7.12.5"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.12.5.tgz#410e7e487441e1b360c29be715d870d9b985882e"
integrity sha512-plcc+hbExy3McchJCEQG3knOsuh3HH+Prx1P6cLIkET/0dLuQDEnrT+s27Axgc9bqfsmNUNHfscgMUdBpC9xfg==
dependencies:
regenerator-runtime "^0.13.4"

"@babel/runtime@^7.14.8", "@babel/runtime@^7.4.4":
version "7.26.0"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.26.0.tgz#8600c2f595f277c60815256418b85356a65173c1"
integrity sha512-FDSOghenHTiToteC/QRlv2q3DhPZ/oOXTBoirfWNx1Cx3TMVcGWQtMMmQcSvb/JjpNeGzx8Pq/b4fKEJuWm1sw==
dependencies:
regenerator-runtime "^0.14.0"

"@babel/types@^7.12.5":
version "7.12.11"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.12.11.tgz#a86e4d71e30a9b6ee102590446c98662589283ce"
Expand Down Expand Up @@ -605,11 +612,11 @@
react-transition-group "^4.4.0"

"@material-ui/icons@^5.0.0-alpha.23":
version "5.0.0-alpha.23"
resolved "https://registry.yarnpkg.com/@material-ui/icons/-/icons-5.0.0-alpha.23.tgz#b7d5141cfaa1df4a9697c60e50df2e5f2c6a0047"
integrity sha512-paML0ghK4qN+Z0oAd66lDfX1+Vt1LBPkMA9uSUEBmGga2yY8aGpo9tAVGM3UR7kTx0BEWT5e/4u2aDvwbdGZPQ==
version "5.0.0-beta.5"
resolved "https://registry.yarnpkg.com/@material-ui/icons/-/icons-5.0.0-beta.5.tgz#54295b9aa120910c88900e3d08082b7acbeb73c0"
integrity sha512-C2KHSf8mvDn22rzsV0UfsJyBYI3Nt/LItcKPJBAG9kgqdBHAuLMH2lfKmdMuX55qd8O+NO5rM7aIHdYQRjfcMQ==
dependencies:
"@babel/runtime" "^7.4.4"
"@babel/runtime" "^7.14.8"

"@material-ui/[email protected]":
version "5.0.0-alpha.19"
Expand Down Expand Up @@ -5284,16 +5291,21 @@ real-require@^0.2.0:
resolved "https://registry.yarnpkg.com/real-require/-/real-require-0.2.0.tgz#209632dea1810be2ae063a6ac084fee7e33fba78"
integrity sha512-57frrGM/OCTLqLOAh0mhVA9VBMHd+9U7Zb2THMGdBUoZVOtGbJzjxsYGDJ3A9AYYCP4hn6y1TVbaOfzWtm5GFg==

regenerator-runtime@^0.13.11, regenerator-runtime@^0.13.7:
regenerator-runtime@^0.13.11, regenerator-runtime@^0.13.4, regenerator-runtime@^0.13.7:
version "0.13.11"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz#f6dca3e7ceec20590d07ada785636a90cdca17f9"
integrity sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==

regenerator-runtime@^0.13.3, regenerator-runtime@^0.13.4:
regenerator-runtime@^0.13.3:
version "0.13.7"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz#cac2dacc8a1ea675feaabaeb8ae833898ae46f55"
integrity sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew==

regenerator-runtime@^0.14.0:
version "0.14.1"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz#356ade10263f685dda125100cd862c1db895327f"
integrity sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==

registry-auth-token@^5.0.1:
version "5.0.2"
resolved "https://registry.yarnpkg.com/registry-auth-token/-/registry-auth-token-5.0.2.tgz#8b026cc507c8552ebbe06724136267e63302f756"
Expand Down

0 comments on commit 7898213

Please sign in to comment.