Correction of a code of a chrome extension
Budget: $10 – $30 USD
I require assistance in correcting the code for a Chrome extension that is designed to extract certain data from a Facebook group post and send it in JSON format to a webhook.
Below are the variables, queries, conditions, and validations. Should you have any questions or need more information, please let me know.
urlGroup:
This is the current URL where the user is located. It must contain the words 'groups' and 'posts'. If not, an alert should be displayed stating, "The URL does not correspond to a post URL. It needs to be reviewed."
For example, a URL might look like this: https://www.facebook.com/groups/310203103859405/posts/902590044620705/
The required part is what's behind '/posts', which is:
https://www.facebook.com/groups/310203103859405
urlPost:
This URL, where the user is currently located, should also contain the words 'groups' and 'posts'. If not, an alert should display, "The URL does not correspond to a post URL. It needs to be reviewed."
There may be cases where the URL is not entirely correct but meets the conditions of having the words 'groups' and 'posts'. If there is a condition where a URL contains the string 'pending_posts', like this example:
https://www.facebook.com/groups/310203103859405/pending_posts/?search=&has_selection=false&is_notif_background=false&post_id=902590044620705
It should be transformed into https://www.facebook.com/groups/310203103859405/ + the value of the 'post_id' variable.
This part will be constant https://www.facebook.com/groups/ + whatever follows after 'groups' is variable (this part can be alphanumeric and numeric) + 'posts/' + the value of the 'post_id' variable.
Group Name (inner text). Var = groupName:
span[class='x193iq5w xeuugli x13faqbe x1vvkbs x1xmvt09 x1lliihq x1s928wv xhkezso x1gmr53x x1cpjm7i x1fgarty x1943h6x xudqn12 x676frb x1lkfr7t x1lbecb7 x1s688f xzsf02u x1yc453h'] a[role='link']
Group Type (inner text), Var = groupType:
div[class='x9f619 x1n2onr6 x1ja2u2z x78zum5 x2lah0s x1nhvcw1 x6s0dn4 xozqiw3 x1q0g3np xexx8yu xwrv7xz x8182xy xmgb6t1 x1kgmq87'] div:nth-child(1)
Number of Members (inner text). Var = groupMembers:
.x1i10hfl.xjbqb8w.x6umtig.x1b1mbwd.xaqea5y.xav7gou.x9f619.x1ypdohk.xt0psk2.xe8uvvx.xdj266r.x11i5rnm.xat24cr.x1mh8g0r.xexx8yu.x4uap5.x18d9i69.xkhd6sd.x16tdsg8.x1hl2dhg.xggy1nq.x1a2a7pz.xt0b8zv.xi81zsa.x1s688f
Number of Reactions (inner text), if not found the value should be 0 (zero). Var = numberReactions:
span[class='xt0b8zv x2bj2ny xrbpyxo xl423tq']
Number of Comments (inner text) remove everything that isn't numbers, if not found the value should be 0 (zero). Var = numberComments:
span[class='x193iq5w xeuugli x13faqbe x1vvkbs x1xmvt09 x1lliihq x1s928wv xhkezso x1gmr53x x1cpjm7i x1fgarty x1943h6x xudqn12 x3x7a5m x6prxxf xvq8zen xo1l8bm xi81zsa']
Send to the webhook in JSON format:
https://webhook.site/9e22f357-b07a-4f70-8eb8-8795437bebc5
userName = testuser
groupName
urlGroup
urlPost
groupType
groupMembers
numberReactions
numberComments
I am sharing the code that needs correction.
Below are the variables, queries, conditions, and validations. Should you have any questions or need more information, please let me know.
urlGroup:
This is the current URL where the user is located. It must contain the words 'groups' and 'posts'. If not, an alert should be displayed stating, "The URL does not correspond to a post URL. It needs to be reviewed."
For example, a URL might look like this: https://www.facebook.com/groups/310203103859405/posts/902590044620705/
The required part is what's behind '/posts', which is:
https://www.facebook.com/groups/310203103859405
urlPost:
This URL, where the user is currently located, should also contain the words 'groups' and 'posts'. If not, an alert should display, "The URL does not correspond to a post URL. It needs to be reviewed."
There may be cases where the URL is not entirely correct but meets the conditions of having the words 'groups' and 'posts'. If there is a condition where a URL contains the string 'pending_posts', like this example:
https://www.facebook.com/groups/310203103859405/pending_posts/?search=&has_selection=false&is_notif_background=false&post_id=902590044620705
It should be transformed into https://www.facebook.com/groups/310203103859405/ + the value of the 'post_id' variable.
This part will be constant https://www.facebook.com/groups/ + whatever follows after 'groups' is variable (this part can be alphanumeric and numeric) + 'posts/' + the value of the 'post_id' variable.
Group Name (inner text). Var = groupName:
span[class='x193iq5w xeuugli x13faqbe x1vvkbs x1xmvt09 x1lliihq x1s928wv xhkezso x1gmr53x x1cpjm7i x1fgarty x1943h6x xudqn12 x676frb x1lkfr7t x1lbecb7 x1s688f xzsf02u x1yc453h'] a[role='link']
Group Type (inner text), Var = groupType:
div[class='x9f619 x1n2onr6 x1ja2u2z x78zum5 x2lah0s x1nhvcw1 x6s0dn4 xozqiw3 x1q0g3np xexx8yu xwrv7xz x8182xy xmgb6t1 x1kgmq87'] div:nth-child(1)
Number of Members (inner text). Var = groupMembers:
.x1i10hfl.xjbqb8w.x6umtig.x1b1mbwd.xaqea5y.xav7gou.x9f619.x1ypdohk.xt0psk2.xe8uvvx.xdj266r.x11i5rnm.xat24cr.x1mh8g0r.xexx8yu.x4uap5.x18d9i69.xkhd6sd.x16tdsg8.x1hl2dhg.xggy1nq.x1a2a7pz.xt0b8zv.xi81zsa.x1s688f
Number of Reactions (inner text), if not found the value should be 0 (zero). Var = numberReactions:
span[class='xt0b8zv x2bj2ny xrbpyxo xl423tq']
Number of Comments (inner text) remove everything that isn't numbers, if not found the value should be 0 (zero). Var = numberComments:
span[class='x193iq5w xeuugli x13faqbe x1vvkbs x1xmvt09 x1lliihq x1s928wv xhkezso x1gmr53x x1cpjm7i x1fgarty x1943h6x xudqn12 x3x7a5m x6prxxf xvq8zen xo1l8bm xi81zsa']
Send to the webhook in JSON format:
https://webhook.site/9e22f357-b07a-4f70-8eb8-8795437bebc5
userName = testuser
groupName
urlGroup
urlPost
groupType
groupMembers
numberReactions
numberComments
I am sharing the code that needs correction.