Skip to content

Commit

Permalink
Improved UX, removed tabs permission #2
Browse files Browse the repository at this point in the history
  • Loading branch information
ManeraKai committed Jul 12, 2023
1 parent bc370c2 commit 33e4d34
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
1 change: 0 additions & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
},
"permissions": [
"storage",
"tabs",
"activeTab",
"https://*/*"
],
Expand Down
20 changes: 14 additions & 6 deletions src/pages/lib/lemmy.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,13 @@ function resolveObject(q, type, options) {
}

function can_lemmy_to_lemmy(url, options) {
if (!options.lemmy) return 'credentials'
return true
for (const regexItem of [regex.post, regex.comment, regex.communityFederated, regex.communityLocal, regex.userFederated, regex.userLocal]) {
if (url.pathname.match(regexItem)) {
if (!options.lemmy) return 'credentials'
return true
}
}
return false
}

function lemmy_to_lemmy(url, options) {
Expand Down Expand Up @@ -105,9 +110,12 @@ function lemmy_to_lemmy(url, options) {
}

function can_lemmy_to_mastodon(url, options) {
if (!options.mastodon) return 'credentials'

for (const regexItem of [regex.userFederated, regex.userLocal, regex.communityFederated, regex.communityLocal]) {
if (url.pathname.match(regexItem)) return true
if (url.pathname.match(regexItem)) {
if (!options.mastodon) return 'credentials'
return true
}
}
return false
}
Expand Down Expand Up @@ -140,10 +148,10 @@ function lemmy_to_mastodon(url, options) {

export default {
isLemmy,

can_lemmy_to_lemmy,
lemmy_to_lemmy,

can_lemmy_to_mastodon,
lemmy_to_mastodon,
regex
Expand Down
13 changes: 10 additions & 3 deletions src/pages/lib/mastodon.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ function isMastodon(url) {
}

function can_mastodon_to_lemmy(url, options) {
if (!options.lemmy) return 'credentials'
for (const regexItem of [regex.userFederated, regex.userLocal]) {
if (url.pathname.match(regexItem)) return true
if (url.pathname.match(regexItem)) {
if (!options.lemmy) return 'credentials'
return true
}
}
return false
}
Expand All @@ -47,7 +49,12 @@ function mastodon_to_lemmy(url, options) {
}

function can_mastodon_to_mastodon(url, options) {
if (!options.lemmy) return 'credentials'
for (const regexItem of [regex.postLocal, regex.postFederated, regex.userFederated, regex.userLocal]) {
if (url.pathname.match(regexItem)) {
if (!options.lemmy) return 'credentials'
return true
}
}
return true
}

Expand Down
1 change: 0 additions & 1 deletion src/pages/popup/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ <h4 data-localise="__MSG_settings__">Settings</h4>
</svg>
</a>
</div>
<div class="space"></div>
<script type="module" src="./popup.js"></script>
</body>

Expand Down

0 comments on commit 33e4d34

Please sign in to comment.