haterapps / fake-data

Fake Data - A form filler you won't hate
39 stars 2 forks source link

Does not show the current URL #23

Closed xyngfei closed 1 year ago

xyngfei commented 1 year ago

let's say I have the site https://mdbootstrap.com/docs/react/forms/input-fields/

put the custom script for id=form1 textbox to return the current UR return document.location.toString()

However, when I tried to generate random test data, it does not show the current URL, any idea?

image

haterapps commented 1 year ago

Hello,

You can use the following code to get the page url:

return function() {
    return document.location.toString();
}

If you need to access elements from window or document objects that belong to the page you are browsing, you will need to return a function (as in the example above). You can find out more about this at the link below: https://docs.fakedata.pro/writing-code/run-in-content-script.html

Thanks!

xyngfei commented 1 year ago

@haterapps thx for your suggestion, it works perfectly fine. however, if I am trying to build-in JS lib, it cannot work again.

return function() {
    return document.location.toString(); + moment().format("yyyyMMDD");
}
xyngfei commented 1 year ago

I miss out this part

It works together with the moment lib