You are not logged in.
For all ...
Since the development process of this little utility for SpaceNut is proceeding from a ground state of close to zero, there is most definitely an opportunity for ** anyone ** to learn a bit about JavaScript by following the examples posted in this topic.
The book I am using as a reference is "Eloquent JavaScript" and the author has kindly placed the text and examples online at his website, at no charge.
I am working with Internet 8 running on Windows XP as a base, on the assumption that anything that works in ** that ** platform will run anywhere.
That assumption was proved wrong, when Visual Studio 2005 suggested <textarea>, and everyone ** after ** 2008 rejected the code.
The <div> statement works perfectly, and it appears that everyone is happy.
Update: The web site at the link below appears to be dealing with collecting data from a web server:
https://www.digitalocean.com/community/ … o-get-data
(th)
Offline
There is a large amount of change in the last code writing for me to study. The api function as well I have seen when I was cleaning the log files too before it was clear that they would be useful to rebuild the forum.
Offline
For SpaceNut re TestID upgrade mini-project ...
The little JavaScript utility has come as far as it can on a 2008 platform.
The next phase needs to pull data from the NewMars web site, and the command for that was published in 2015.
Meanwhile, I posted a question about the procedure to return the TestID usernames to member status.
From the example provided by kbd512, I get the impression all you've had to do is to "Remove" the username from the bans table.
I noticed that a Moderator can perform that function.
Is there anything you've been doing other than clicking the "Remove" button?
If not, then I could (presumably (and with your permission)) take care of that so you don't have to.
(th)
Offline
For SpaceNut re TestID mini-project ...
Just FYI ... I downloaded Microsoft Visual Studio Code.
It is just an editor, but it appears to be optimized for JavaScript.
It takes up about 330 Mb of hard drive space.
I decided to make the leap from 2008 to 2022 when I discovered the Fetch command that is needed to pull queries from NewMars was added to JavaScript in 2015.
(th)
Offline
For SpaceNut re JavaScript TestID update utility...
https://www.dropbox.com/s/c4aafbanwggih … t.htm?dl=0
This is version 13 ... the changes are teeny-tiny in the program. However, the work environment here has leaped from 2008 to 2022 with updates to Visual Studio Code coming in while the program is in use.
If you can fit Visual Studio Code into your PC I'd be interested in your observations. The test environment seems seamless, but I haven't caused any errors, so I can't really report on that.
What I ** can ** report is that a new function #5 is able to deliver text at run time, and it shows up in the output. I am hoping to fetch information about a TestID in the bans table in the next go-round.
There's a bit more involved in using the Fetch command than I'm ready for today.
The new command (apparently) "promises" to deliver data some time in the future, and that is a reasonable concept from my point of view, since the Smart Wait I wrote for WBA has to put up with variable amounts of wait time as FluxBB does it's thing.
A delay that ** should ** go away by converting to JavaScript is the delay caused by the browser saving the history of transactions, and reviewing that entire history when a new transaction occurs. I recently saw a history of 32 megabytes, although about 5 megabytes is normal for 1000 posts.
If you get a chance to run this latest version, please don't hesitate to confirm you can see the output of function #5.
(th)
Offline
The testid# is from the forms page under the admin ban links and while the remove is a link on the page it runs a script once the link is hit or selected and afterwards it's going to do a refresh and you will be back at the form once more.
I see no reason that you cannot go ahead with the unban of them.
For the usernames side I am clearing the reason for action at the bottom of those profiles page that you have been doing the outreach.
Offline
For SpaceNut re #68 ... Thanks for the all-clear to try removing the TestID's from the bans table.
Today is "volunteer" day here, so NewMars will be on hold.
The next phase of development is an attempt to use Fetch to pull a query from the NewMars site.
The Fetch command is described as a "method" rather than a function, so I suppose that means it has the same standing in the hierarchy as function. Fetch has a built-in try-catch structure. One path delivers the results desired, and the fail side reports what didn't happen. A typical error is a 404 error for resource not found.
As I read the documentation, Fetch is often or perhaps usually paired with "await".
At this point, I have no idea what the browser will deliver when it is asked to fetch the Query result for one of the TestIDs. Options are "text" and "JSON" and I'll start with "text" to see if the output makes sense.
The ** next ** challenge is to try to figure out how to use Fetch to POST the Remove.
The example of Katalon that kbd512 provided shows a direct address of the "Remove" button.
At this point I have no idea what the equivalent JavaScript command might be.
(th)
Offline
As a follow up ...
For SpaceNut ...
Here is a report of an experiment to see if a Moderator can restore a banned user (ie, TestID) to member status...
Query to see TestID's in bans table:
Before:
TestID11401 testid11401@test.com Never SpaceNut Edit | Remove
Query to see TestID11401 in Users Table:
TestID11401 Banned 0 2018-02-14
Action: Remove TestID11401 from Bans table
Result shown in Users table:
TestID11401 Member 0 2018-02-14
I noticed that FluxBB prepared a special update query to perform the Remove operation.
That would presumably be the correct format to use for an automated procedure.
TestID11402
The query to bring up an individual member in the bans table is:
http://newmars.com/forums/admin_bans.ph … estID11402
A query to perform the unban looks like this:
newmars.com/forums/admin_bans.php?del_ban=#####
In the example above, ##### is the ID of the record in the bans table
(th)
Offline
When I ran it sure the information went into the boxes but did not do anything to the actual id.
I might not have done something correctly?
I see that another testid # was moved but as I can see the reason for the change to create information in conversion is still present the script is still being tested. Looks like we might need to write a trace to see what the remove function code looks like to follow what to do in command line.
Offline
For SpaceNut re development of utility to upgrade TestID's from banned to member.
Thanks for noting my experiments in manual mode.
I've been collecting data on how the system behaves ... I published the command to pull a query for one TestID in the bans table recently, but at this point I don't remember if that is in the Java topic or the Housekeeping topic.
My plan is to send that command to the FluxBB server to request just one TestID at a time.
Based upon previous work with the Web Browser Automation program, I'm thinking of performing verification procedures at every step.
In reading your post #69, I'm wondering if there is a need for a text message explaining why the user was restored to member? If there ** is ** such a feature, I'm not seeing it as a Moderator. All I see is a pair of buttons: Edit or Remove.
My assumption (until now) has been that all I have to do is to click on the Remove button.
If you think back to the Katalon script that kbd512 wrote for you, that is all he did.
There's plenty of time for you to provide additional direction.
My plan for a test this evening is to simply see if I can persuade FluxBB to deliver one record from the bans table.
I'm not planning to perform any updates until that part of the script is working.
(th)
Offline
That is the posted content in post 12 so if I add that to the current script that you are writing I should be able to get a running unban function less user message information.
Offline
For SpaceNut re JavaScript TestID update utility....
As reported earlier, I am approaching the TestID update opportunity from two directions ... the tried-and-true WBA system is more than capable of doing the job, now that I understand that Moderators can perform the Remove function.
However, I am ** really ** interested in learning how to use JavaScript to do the job, because having a tool that will run anywhere is ** far ** more useful.
The next phase of development of the WBA script is to use the Mouse Position Location utility to identify the location of the Remove button. That will happen later today, and I expect the script to be fully operational later today. The opening and closing segments of the script are finished and tested.
Only the Remove click needs to be added, along with a bit more validation to make sure the work was done correctly.
I am looking forward to my first attempt to write a JavaScript Fetch.
The examples (online and in Eloquent JavaScript) look simple enough, but complexity often reveals itself in situations like this.
(th)
Offline
For SpaceNut .... here is a teeny-tiny update to the version of the TestID script that is now running on a Windows 10 machine, using Visual Studio Code as the development environment, and with Edge as the browser.
https://www.dropbox.com/s/uf286iiidbr01 … t.htm?dl=0
Please use 11404 as your test number. I don't have any formatting installed, so using that five digit number provides a match with the needed URL format.
I'll tackle the actual "Fetch" tomorrow. It was enough for today to just put the url together as a text item.
(th)
Offline
For all... if there is a JavaScript expert in the crowd, I'd appreciate a hint about how to provide five digits of output from the ToString method.
In other languages, there are "format" methods that take arguments like "#####" so that if a source number is fewer than 5 digits, the output will be presented with leading zeros.
Since I am just now (trying to) learning JavaScript, and that part of the language is far away in Eloquent JavaScript, I'm more than happy to accept a hint if anyone has one.
As a reminder, Eloquent JavaScript is available for free download from the author's web site.
(th)
Offline
For SpaceNut re Fetch command ...
My first attempt to use this command failed ... that is not a surprise!
What would have been a surprise is if it had worked!
Run Status
Progress detail is to be reported here
Current ID is: 11701After Fetch - should NOT appear
This version ran on Edge on Windows 10Development environment is Visual Studio Code
The entire Fetch block seems to have been ignored.
The line that says it should NOT appear was after the new block.
Here is what the debug window reported:
Uncaught TypeError TypeError: Failed to fetch
at fx5_run (c:\Users\tahan\Documents\20221017SampleHtmlJavascript.htm:93:13)
at fx4_run (c:\Users\tahan\Documents\20221017SampleHtmlJavascript.htm:81:70)
at onclick (c:\Users\tahan\Documents\20221017SampleHtmlJavascript.htm:127:82)
--- Promise.then ---
at fx5_run (c:\Users\tahan\Documents\20221017SampleHtmlJavascript.htm:93:30)
at fx4_run (c:\Users\tahan\Documents\20221017SampleHtmlJavascript.htm:81:70)
at onclick (c:\Users\tahan\Documents\20221017SampleHtmlJavascript.htm:127:82)
A bit later ... I added some sample code from:
bobbyhadz.com/blog/javascript-typeerror-failed-to-fetch-cors
Run Status
Progress detail is to be reported here
Current ID is: 11701[object Promise]
This version ran on Edge on Windows 10Development environment is Visual Studio Code
That return of [object Promise] is encouraging.
I'll upload this version as a "work in progress"
(th)
Offline
For SpaceNut re TestID update using JavaScript
https://www.dropbox.com/s/j9r8j80leyypg … t.htm?dl=0
Above link brings up a script that ** sort of ** runs, thanks to some sample code provided by a generous blogger.
However, the output is a long way from what is needed.
Tonight is the meeting of the local Linux User Group, and the leader of the group used to teach Java at a local community college. I'm hoping the group will be interested in looking at the TestID program in it's current state. They like having something to chew on during meetings, which are online since Covid and while they do have meeting facilities, the convenience of online, PLUS the convenience of screen sharing with their Professional Zoom makes online nice for everyone.
I am hoping other attendees are NOT JavaScript experts, so everyone can learn a little bit as we debug my code.
Update a bit later... testing on a Chromebook:
Console log shows this:
20221017SampleHtmlJavascript.htm:1 Access to fetch at 'http://newmars.com/forums/admin_bans.ph … estID11701' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
20221017SampleHtmlJavascript.htm:100
GET http://newmars.com/forums/admin_bans.ph … estID11701 net::ERR_FAILED
getUser @ 20221017SampleHtmlJavascript.htm:100
fx5_run @ 20221017SampleHtmlJavascript.htm:113
fx4_run @ 20221017SampleHtmlJavascript.htm:81
onclick @ 20221017SampleHtmlJavascript.htm:15320221017SampleHtmlJavascript.htm:109 TypeError: Failed to fetch
StackExchange has a long discussion about this error ... (CORS) ...
https://stackoverflow.com/questions/438 … source-whe
I'm glad we have a meeting of the Linux group coming up. Good Grief!
(th)
Offline
For SpaceNut re JavaScript ....
Apparently the CORS issue is well known and well documented, and ? apparently ? there may be a way (or two) around it.
This issue does not come up in Eloquent JavaScript because the examples (apparently) all involve working from the local hard drive.
Here is an example of some of the advice on offer:
Fortunately, there is a free proxy server named CORS Anywhere which adds CORS headers to the proxied request. To solve this issue easily with javascript, we will make an ajax request as you always do with XMLHttpRequest or jQuery ajax but we'll use the cors-anywhere service, which allow us to bypass this problem.
How to bypass 'Access-Control-Allow-Origin' error with XMLHttpRe…
ourcodeworld.com/articles/read/73/how-to-bypass-access-control-allow-origin-error-with-xmlhttprequest-jquery-ajax-
ourcodeworld.com/articles/read/73/how-to-bypass-access-control-allow-origin-e…
Was this helpful?
People also ask
I found another resource who offers to show how to bypass the problem with "plain vanilla JavaScript"
Update a bit later: Apparently these two folks are offering the same solution:
https://dev.to/cigwe416/fix-cors-error-javascript-1na2
The author at the site above provided a sample code to use a third party web site as a proxy to overcome CORS
Here is a URL provided by the author above. It works...
http://api.forismatic.com/api/1.0/?meth … ormat=json
However, when embedded within the CORS fix package, it does not get a chance to work.
This is the output when the URL is transmitted from a browser:
{"quoteText":"A man is not where he lives but where he loves.", "quoteAuthor":"", "senderName":"", "senderLink":"", "quoteLink":"http://forismatic.com/en/393d7bb026/"}
So ** that ** is what we should see if we can get the proxy to work
Update a bit later: Here is the URL of the proxy server. It works (as nearly as I can tell)
https://cors-anywhere.herokuapp.com/corsdemo
Update a bit later: The concatenation of the two URL's also works:
https://cors-anywhere.herokuapp.com/htt … ormat=json
OK ... changed lookup to NewMars and type from json to text ... now got these outputs...
Response {type: 'cors', url: 'https://cors-anywhere.herokuapp.com/htt … erman_2022', redirected: false, status: 200, ok: true, …}
20221017SampleHtmlJavascript.htm:106 {data: '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Stric…v class="end-box"></div>\n</div>\n\n</body>\n</html>\n'}
I'm not sure, but I ** think ** (possibly?) the second reply might be from NewMars?
Update a bit later ... sure enough! When I loaded the NewMars Username query, the top matched what the JavaScript is showing...
data did not copy so I'll have to try to get it again
It's probably just as well the copy did not work ... the data went on for multiple pages ...
Here are a few lines from the top:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr"><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>User list / New Mars Forums</title>
<link rel="stylesheet" type="text/css" href="style/Fire.css">
</head><body onload="document.getElementById('userlist').elements['username'].focus()">
It's time to go back to the resources to see if there is another solution to the CORS problem.
(th)
Offline
For SpaceNut ... the latest attempt generated a 403 (forbidden) error ...
A bit later ...
Here is the console log when the Fetch was given the original request, using the proxy
The problem NOW seems to be that the JavaScript does not have permission to do Moderator queries.
I had hoped that since the browser was logged into NewMars as Moderator, the JavaScrip would receive privileges.
Apparently not.
There may be some advice on how to log into a web site using JavaScript.
A pop-up Username and Password would do the trick.
However, in the mean time, here is the 403 error:
20221017SampleHtmlJavascript.htm:103
GET https://cors-anywhere.herokuapp.com/htt … n_bans.php?
find_ban=Submit+search&form%5Busername%5D=TestID11701 403 (Forbidden)
<<== looky looky !!! Not logged ingetQuote @ 20221017SampleHtmlJavascript.htm:103
fx5_run @
20221017SampleHtmlJavascript.htm:112
fx4_run @
20221017SampleHtmlJavascript.htm:81
onclick @
20221017SampleHtmlJavascript.htm:151
20
221017SampleHtmlJavascript.htm:104 Response {type: 'cors',
url: 'https://cors-anywhere.herokuapp.com/
http://newmars…_ban=Submit+search&form%5Busername%5D=TestID11701',
redirected: false, status: 403, ok: false, …}20221017SampleHtmlJavascript.htm:106 {data: '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Stric…v class="end-box">
</div>\n</div>\n\n</body>\n</html>\n'}
(th)
Offline
In reading a bit more about CORS, I get the impression this is not going to be easy to fix.
The discussion at the web site referenced below seems to indicate something needs to be done at the server to grant access.
On the ** other ** hand, kbd512 was able to perform updates using his Katalon script, and he did not report CORS issues.
https://developer.okta.com/blog/2021/08 … blems-cors
Many websites have JavaScript functions that make network requests to a server, such as a REST API. The web pages and APIs are often in different domains. This introduces security issues in that any website can request data from an API. Cross-Origin Resource Sharing (CORS) provides a solution to these issues. It became a W3C recommendation in 2014. It makes it the responsibility of the web browser to prevent unauthorized access to APIs. All modern web browsers enforce CORS. They prevent JavaScript from obtaining data from a server in a domain different than the domain the website was loaded from, unless the REST API server gives permission.
From a developer’s perspective, CORS is often a cause of much grief when it blocks network requests. CORS provides a number of different mechanisms for limiting JavaScript access to APIs. It is often not obvious which mechanism is blocking the request. We are going to build a simple web application that makes REST calls to a server in a different domain. We will deliberately make requests that the browser will block because of CORS policies and then show how to fix the issues. Let’s get started!
NOTE: The code for this project can be found on GitHub.
(th)
Offline
Google found this reference for the issue of CORS interfering with a request for data from the NewMars server.
https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
The underlying issue is the same one SpaceNut has been dealing with, and the Admins before him.
JavaScript is a tool that can be (and has been) used to attack web sites.
CORS is (apparently) an industry attempt to deal with those attacks.
There appears to be a work-around using a proxy server.
As reported earlier in this topic, a proxy server can "solve" the CORS problem by forwarding a request.
However, the demo proxy server is NOT intended to be used for production work.
I would note (again) that the Katalon server for which kbd512 wrote a script apparently does not have this problem.
https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
The document above was recommended by Google. I've read enough to know it deserves a fresh start on another day.
The answer may be in there, but late at night after a long day is not the optimum time to find it.
Update later:Tips on how to log in using JavaScript
https://stackoverflow.com/questions/554 … javascript
(th)
Offline
Java like all software has gone through many versions and OS that it can be run on plus other non-java virtual machines. Not all Java work the same as it's the old windows versus sun product.
https://docs.katalon.com/docs/legacy/ka … et-started
The ban table now starts with TestID11835...were you able to get a script to work? Or did you do this manually?
I notice that kbd512 is java and not javascript
Offline
For SpaceNut re #71
Thank you for your insights about the possible difference between Java and JavaScript!
The languages are indeed different. The only connection between them is that the creator of JavaScript was impressed by the success of Java, and decided to catch a ride with a similar name.
Thanks for the link to information about Katalon !!! I'll follow the link a bit later today.
I got a script to work on the TestID problem, and it is chewing away at the TestID pool at the rate of 300 per day. It will take just under a month to finish the job.
Meanwhile, my intention is to (at least try to) discover if there is a solution to the CORS problem. The issue seems to be that all browser writers have been asked to implement CORS to address hacking. What I'm mystified by (at this point) is what is going on that sets off a security alert, so that the browser refuses to carry out what seems (to me at least) like a reasonable request.
The difference with the WBA system is that it actually simulates a ** real ** human operator, working at the keyboard and mouse.
JavaScript runs as a program given to a browser for execution. As I understand the problem, all browsers will balk if asked to send a request to a foreign server if JavaScript makes the request. On the ** other ** hand, if code supplied by the server (ie, a web page), makes the request, then it is OK.
I sure am glad I made the decision long ago to go with the simulated human operator solution.
I'll keep trying to find a solution using JavaScript, but progress is not being held up due to the security issues.
PS ... I haven't checked last night's run, but the TestID run should have reached 12000 last nigjht. It started from 11701.
I'll report the status of the run shortly.
(th)
Offline
For SpaceNut re Security issues with JavaScript ....
In attempting to understand the problem yesterday, I confirmed that a demo proxy server could provide access to the NewMars server for a JavaScript request.
The issue there is that the demo proxy server is provided as a courtesy for developers, and it is NOT intended to be used for a production solution.
In reading some of the vast amount of information about CORS, I learned that the server (in our case NewMars) can provide an authorization for otherwise illegal access requests. At this point, I have no idea if the NewMars server contains this code.
A possibility is to create a proxy server just to permit JavaScript to send requests to NewMars. That seems like an unwieldy solution at best.
The local Linux meeting is this evening, so I'll have a problem to offer them for consideration.
(th)
Offline
For anyone studying the CORS vs JavaScript issue ...
https://developer.okta.com/blog/2021/08 … blems-cors
Access-Control-Allow-Origin: http://localhost:8080
If a server has Access-Control-Allow-Origin: *
then CORS will grant the request.
It seems unlikely that NewMars would have such a setting.
(th)
Offline
More for anyone studying the CORS vs JavaScript issue...
Per Google:
how to set up a proxy server to bypass cors restrictions on javascript
Camera searchAll
VideosImagesNewsBooksMore
Tools
About 118,000 results (0.71 seconds)Bypassing CORS via custom proxy backendhttps://dev.to › bornfightcompany › bypassing-cors-via...
Dec 12, 2021 — Open index.js (or whatever you called it in the previous step) so we can create our server. I will copy all the code required here, along ...
Cors Intro · Express Backend · Additional Bonus: Data...
VideosPREVIEW
12:58
AM Coder - Making Your Own Proxy Server to Avoid CORS ...
YouTube · Alex Merced - Full Stack Developer
Nov 19, 2020
This appears to be a cottage industry...
(th)
Offline