Google Alerts is a very handy and powerful service to stay informed of what's happening in a particular field.
I'm a huge fan of this service and...
For further actions, you may consider blocking this person and/or reporting abuse
I get an error with unexpected token '.'
debugger:///VM90496
Attached is the screenshot...dev-to-uploads.s3.amazonaws.com/i/...
I assume you don't need a const and var for keywords? I also got an error saying keywords had been defined already. Probably user error but missing a step here...
Thanks!
Total NEWB - just needed to remove the ';' from after the fetch which ended the statement...that said I got a notification that it added my keywords however when I refresh I only see it added ${keyword} to my alerts....?? Is this right: 22${keyword}%22
Hi there, im getting the same. the Javascript code works but it adds an alerts with the actual text '${keyword}' as the term to be looked up in the alert. I can't make the code work to extract the ${keyword} value and use it to set the alert :(
Anyone worked this out? Thanks so much!!!
Fixed!!! The issue is that having the 'params' inside an string like this:
"params=hexcode${keyword}hexcode" makes the interpreter to not extract the value for ${keyword}
Instead of that in your code define 2 new var like this:
var left = "params=hexcode%22"
This var has 'all the text on the left of the actual keyword you want to add'
var right = "%22hexcode"
This var has 'all the text on the left of the actual keyword you want to add'
Now in addAlert(i) build a new params var containing the term you want to add in your google alert like this:
function addAlert(i) {
// Retrieve the keyword to work with
const keyword = encodeURIComponent(keywords[i])
//build the params var with the term to be added
var params = left + keyword + right
And all that's left is to use it (without any '$') in your fetch getting something like this:
"referrer": "google.es/alerts",
"referrerPolicy": "strict-origin-when-cross-origin",
"body": params,
"method": "POST",
"mode": "cors",
"credentials": "include"
I hope this will help anyone!!!
I got as far as being able to create a Google alert. However, instead of creating separate alerts for every search term assigned to var 'keywords', it creates one alert comprised of each search term separated by commas, i.e. one concatenated search string. Can anyone assist? TIA.
I figured out the issue. I was using davideladio's fix but accidentally declared the param variable with the keywords variable instead of the keyword constant. Deleting the 's' fixed the issue!
What you added worked very well!
I have a ridiculous problem.
Id like to use quotation marks in my keywords and darn it- can't work it.
The regular escape character for quotation marks don't work.
var keywords=[" \"Topic One\" " , " \"Topic Two\" "]
and it gives a 404 error here-
fetch("google.com/alerts/create?x=AMJHsmW...", {
blaah blah}
Thank you!
I am having the same issue without using quotation marks in my keywords. Were you able to fix this?
There's a bug in the script
everytime I run it it shows the following error on this line :
.then(() => { setTimeout(function() {addAlert(i+1)}, (Math.min(i || 2, 30) * 1000)) })
Uncaught SyntaxError: Unexpected token '.'
After a trial I found the error is the ";" just before the ".then" line
You just need to remove it
Regards
Hello, anyone have a script to add google alerts in bulk?
check it out
Trying this in 2023 and getting 404 errors when attempting to run the fetch() code. Anyone have ideas?