Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mastodon-bookmarks
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MickGe
mastodon-bookmarks
Commits
22b538cb
Verified
Commit
22b538cb
authored
1 year ago
by
MickGe
Browse files
Options
Downloads
Patches
Plain Diff
add reload button
parent
ef32e707
Branches
dev
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
action-bar.js
+16
-2
16 additions, 2 deletions
action-bar.js
main.js
+8
-4
8 additions, 4 deletions
main.js
mastodon-api.js
+2
-1
2 additions, 1 deletion
mastodon-api.js
with
26 additions
and
7 deletions
action-bar.js
+
16
−
2
View file @
22b538cb
import
{
loadContent
}
from
"
./main.js
"
;
export
const
actionBar
=
document
.
createElement
(
'
div
'
);
actionBar
.
classList
.
add
(
'
actionbar
'
);
...
...
@@ -11,8 +13,13 @@ actionBar.appendChild(cleanCookiesButton);
cleanCookiesButton
.
innerHTML
=
"
🍪
"
;
cleanCookiesButton
.
title
=
"
Cliquer pour supprimer les cookies
"
;
const
reloadButton
=
document
.
createElement
(
'
button
'
);
actionBar
.
appendChild
(
reloadButton
);
reloadButton
.
innerHTML
=
"
⟳
"
;
reloadButton
.
title
=
"
Cliquer pour recharger
"
;
const
reverseSort
=
()
=>
{
const
newsFeedEl
=
document
.
querySelector
(
"
.
news-feed-el
"
);
const
newsFeedEl
=
document
.
getElementById
(
"
news-feed-el
"
);
newsFeedEl
.
classList
.
toggle
(
'
reverse
'
);
}
...
...
@@ -21,5 +28,12 @@ const cleanCookies = () => {
document
.
cookie
=
'
instanceURL=""; expires=Thu, 01 Jan 1970 00:00:01 GMT"; samesite=lax; secure
'
;
}
const
reload
=
()
=>
{
const
newsFeedEl
=
document
.
getElementById
(
'
news-feed-el
'
);
document
.
getElementById
(
'
app
'
).
removeChild
(
newsFeedEl
);
loadContent
();
}
sortButton
.
addEventListener
(
'
click
'
,
reverseSort
);
cleanCookiesButton
.
addEventListener
(
'
click
'
,
cleanCookies
);
\ No newline at end of file
cleanCookiesButton
.
addEventListener
(
'
click
'
,
cleanCookies
);
reloadButton
.
addEventListener
(
'
click
'
,
reload
);
\ No newline at end of file
This diff is collapsed.
Click to expand it.
main.js
+
8
−
4
View file @
22b538cb
...
...
@@ -16,15 +16,19 @@ const instanceURL = new URL(promptURL);
document
.
cookie
=
`token=
${
token
}
; max-age=604800; samesite=lax; secure`
;
document
.
cookie
=
`instanceURL=
${
encodeURIComponent
(
instanceURL
)}
; max-age=604800; samesite=lax; secure`
;
const
appendChildr
en
=
async
()
=>
{
export
const
loadCont
en
t
=
async
()
=>
{
const
content
=
await
getData
(
instanceURL
,
token
);
document
.
querySelector
(
'
#app
'
).
appendChild
(
actionBar
);
document
.
querySelector
(
'
#app
'
).
appendChild
(
content
?.
newsFeedEl
||
content
);
document
.
querySelector
(
'
#bm_nb
'
).
textContent
=
content
?.
bookmarksNb
||
"
Ø
"
;
document
.
getElementById
(
'
app
'
).
appendChild
(
content
?.
newsFeedEl
||
content
);
document
.
getElementById
(
'
bm_nb
'
).
textContent
=
content
?.
bookmarksNb
||
"
Ø
"
;
if
(
content
?.
bookmarksNb
)
document
.
title
=
`
${
content
.
bookmarksNb
}
Mastodon unBookmarks`
;
}
const
appendChildren
=
()
=>
{
document
.
getElementById
(
'
app
'
).
appendChild
(
actionBar
);
loadContent
();
}
appendChildren
();
// YaehBqDsKZwFtM7Nqa0ZO7TPE9RKQ_kMgzRNoRu7PZ0
\ No newline at end of file
This diff is collapsed.
Click to expand it.
mastodon-api.js
+
2
−
1
View file @
22b538cb
const
newsFeedEl
=
document
.
createElement
(
'
div
'
);
newsFeedEl
.
classList
.
add
(
'
news-feed-el
'
);
newsFeedEl
.
id
=
'
news-feed-el
'
;
const
newsFetch
=
async
(
url
,
token
)
=>
{
const
response
=
await
fetch
(
url
,
{
mode
:
"
cors
"
,
headers
:
{
Authorization
:
`Bearer
${
token
}
`
}})
...
...
@@ -21,7 +22,7 @@ const unbookmark = async (url, token, id, card) => {
.
then
((
res
)
=>
{
if
(
res
.
ok
)
{
card
.
classList
.
add
(
'
disappeared
'
);
const
bookmarksNb
=
document
.
querySelector
(
'
#
bm_nb
'
).
textContent
-=
1
;
const
bookmarksNb
=
document
.
getElementById
(
'
bm_nb
'
).
textContent
-=
1
;
document
.
title
=
`
${
bookmarksNb
}
Mastodon unBookmarks`
;
}
else
{
console
.
error
(
'
*** Bookmark not unbookmarks ***
'
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment