-
-
Save codemicro/f7d4d4b687c3ec2e7186ef7efecfcc35 to your computer and use it in GitHub Desktop.
javascript:(() => { | |
const requestURL = "http://127.0.0.1:8080/api/readingList"; | |
const token = "dfgkjlhsdfgkljghklhj"; | |
const pageTitle = document.title; | |
const pageURL = window.location.href; | |
let metaImage = ""; | |
let metaDescription = ""; | |
function getMetaValue(propName) { | |
const x = document.getElementsByTagName("meta"); | |
for (let i = 0; i < x.length; i++) { | |
const y = x[i]; | |
let metaName; | |
if (y.attributes.property !== undefined) { | |
metaName = y.attributes.property.value; | |
} | |
if (y.attributes.name !== undefined) { | |
metaName = y.attributes.name.value; | |
} | |
if (metaName === undefined) { | |
continue; | |
} | |
if (metaName === propName) { | |
return y.attributes.content.value; | |
} | |
} | |
return undefined; | |
} | |
{ | |
let desc = getMetaValue("og:description"); | |
if (desc !== undefined) { | |
metaDescription = desc; | |
} else { | |
desc = getMetaValue("description"); | |
if (desc !== undefined) { | |
metaDescription = desc; | |
} | |
} | |
} | |
{ | |
const img = getMetaValue("og:image"); | |
if (img !== undefined) { | |
metaImage = img; | |
} | |
} | |
console.log("BOOKMARKET PRESSED:", pageTitle, pageURL, metaDescription, metaImage); | |
const url = new URL(requestURL); | |
const searchParams = url.searchParams; | |
searchParams.set("title", pageTitle); | |
searchParams.set("url", pageURL); | |
searchParams.set("description", metaDescription); | |
searchParams.set("image", metaImage); | |
searchParams.set("nexturl", pageURL); | |
searchParams.set("token", token); | |
window.location.href = url; | |
})(); |
Not at all! Glad to see you like it!
you may be interested, I created this file hosted by github here https://read.jamesst.one/save
so I can use your bookmarklet with no server
ie just setting:
const requestURL = "https://read.jamesst.one/save ";
with my PAT
That's pretty neat!
You'll also probably want to change this email address: https://github.com/jamesmstone/readingList/blob/c5b7f2f3a2f5a59923bd995a5991e436948c845e/.github/workflows/append.yml#L32
ahh good catch - thanks
Hey ! Thanks a lot to both of you for sharing !
I did build on both your codes, and added the possibility to add a rating to a reading, which I use through a folder of bookmarklets
Code is here for those interested : https://github.com/ycouble/readingList
That's a super cool extension to it, thanks for sharing!
the power of open source! 💪
Thanks! I am going to start using a fork of your exact process!
https://read.jamesst.one
https://github.com/jamesmstone/readingList
Hope you don't mind!