Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
netzradar-yourls-downloader
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
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IDA
netzradar-yourls-downloader
Commits
d0b986ce
Commit
d0b986ce
authored
Jul 9, 2024
by
Jan Seipel
Browse files
Options
Downloads
Patches
Plain Diff
initial commit
parents
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
netzradar-yourls-downloader.user.js
+56
-0
56 additions, 0 deletions
netzradar-yourls-downloader.user.js
with
56 additions
and
0 deletions
netzradar-yourls-downloader.user.js
0 → 100644
+
56
−
0
View file @
d0b986ce
// ==UserScript==
// @name netzradar-yourls-downloader
// @namespace http://tampermonkey.net/
// @version 2024-07-09
// @description Lädt Daten aus unserer Yourls-Instanz als CSV herunter
// @author You
// @match http://x.swr.de/a/admin/*
// @grant none
// ==/UserScript==
(
function
()
{
'
use strict
'
;
const
getDataFromRow
=
(
d
)
=>
{
const
shortURL
=
d
.
querySelector
(
"
td.keyword > a
"
).
href
const
title
=
d
.
querySelector
(
"
td.url > a
"
).
title
const
link
=
d
.
querySelector
(
"
td.url > a
"
).
href
const
unixTime
=
d
.
querySelector
(
"
span.timestamp
"
).
innerText
const
dateObj
=
new
Date
(
unixTime
*
1000
)
const
dateStr
=
dateObj
.
toISOString
().
split
(
"
T
"
)[
0
]
const
clicks
=
d
.
querySelector
(
"
td.clicks
"
).
innerText
return
'
"
'
+
[
shortURL
,
title
,
link
,
dateStr
,
clicks
].
join
(
'
";"
'
)
+
'
"
'
}
const
createCSV
=
()
=>
{
const
rows
=
document
.
querySelectorAll
(
"
tr[id^='id-']
"
)
const
rowData
=
[...
rows
].
map
((
d
)
=>
getDataFromRow
(
d
))
const
csv
=
rowData
.
join
(
"
\n
"
)
return
csv
}
const
createDownload
=
()
=>
{
const
csv
=
createCSV
()
const
a
=
document
.
createElement
(
'
a
'
);
a
.
href
=
'
data:application/csv;charset=utf-8,
'
+
encodeURIComponent
(
csv
);
//supported by chrome 14+ and firefox 20+
a
.
download
=
'
yourls-data.csv
'
;
//needed for firefox
document
.
getElementsByTagName
(
'
body
'
)[
0
].
appendChild
(
a
);
//supported by chrome 20+ and firefox 5+
a
.
click
();
}
const
createDownloadButton
=
()
=>
{
let
btn
=
document
.
createElement
(
"
input
"
)
btn
.
type
=
"
button
"
btn
.
value
=
"
Download csv
"
btn
.
className
=
"
button
"
btn
.
onclick
=
()
=>
createDownload
()
document
.
getElementById
(
"
filter_buttons
"
).
appendChild
(
btn
)
}
createDownloadButton
()
})();
\ No newline at end of file
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