I have this code that I am trying to use as a bookmarklet.
fetch('https://hf.space/embed/Alifarsi/news_summarizer/+/api/predict/', { method: "POST", body: JSON.stringify({"data":[ "https://www.cp24.com/news/ontario-reports-481-new-covid-19-cases-1-death-1.5667950"]}), headers: { "Content-Type": "application/json" } }).then(function(response) { return response.json(); }).then(function(json_response){ console.log(json_response) })
I got the code from:
https://hf.space/embed/Alifarsi/news_summarizer/api
Usually the bookmarklets start with "javascript:" keyword. I tried to added that at the start of the string, but it did not fetch the expected page.
Update:
May be I have not explained what I am trying to achieve:
Drag & Drop the bookmarklet: https://codepen.io/shantanuo/pen/LYWRabE
Visit a tech page for e.g. https://pandas.pydata.org/docs/reference/api/pandas.read_csv.html
Click on the bookmarklet when you the active tab is showing the contents of the page mentioned above.
You will see the stack-overflow questions where this page is referred. If this works, I thought I can get the summary of current page using the API that will save my time reading the entire article. But this does not seem to be as easy as the process mentioned above.
Chrome blocks bookmarklets using fetch() on a new Tab. Try running it as a bookmarklet on another site like for example https://w3c.github.io, and it should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With