chiark / gitweb /
rm jquery
authorMarnanel Thurman <marnanel@thurman.org.uk>
Sun, 12 Dec 2021 04:49:16 +0000 (04:49 +0000)
committerMarnanel Thurman <marnanel@thurman.org.uk>
Sun, 12 Dec 2021 04:49:16 +0000 (04:49 +0000)
App.js
grok.js

diff --git a/App.js b/App.js
index 89be8b0ead88c683df2774ec84a28b87f74b17be..221590c6475eb07d4ed5e3e9bfe1f593d9d8457d 100644 (file)
--- a/App.js
+++ b/App.js
@@ -11,7 +11,6 @@ import {
     grok_url,
 } from './grok.js';
 import logo from './assets/images/logo.png';
-import $ from 'jquery';
 
 export default class App extends React.Component {
 
@@ -58,7 +57,7 @@ export default class App extends React.Component {
     };
 
     ui_login_show_message(message) {
-        $("#login-message").show().text(message);
+        this.state.message = message;
         console.log(message);
     };
 
diff --git a/grok.js b/grok.js
index f9668853fe4c634b33b4b0a95e8082cb2e9d74b8..96ac3c77c3cc127fe717647de4b8c7c548d9737e 100644 (file)
--- a/grok.js
+++ b/grok.js
@@ -10,7 +10,6 @@ import {
 
 import * as SecureStore from 'expo-secure-store';
 import tough from 'tough-cookie';
-import $ from 'jquery';
 
 ///////////////////////////////////////
 
@@ -86,11 +85,13 @@ export async function grok_login1() {
             },
         }).then((response) => {
 
-            var html = $('<html>').append(
-                $.parseHTML(response.data));
+            var parser = new DOMParser();
+            var doc = parser.parseFromString(
+                response.data, 'text/html');
 
-            result['auth'] = html.find('[name="lj_form_auth"]').
-                attr('value');
+            result['auth'] = doc.querySelectorAll(
+                'name="lj_form_auth"]')[0].
+                getAttribute('value');
 
             result['cookies'] = cookie_string(response);
 
@@ -130,17 +131,22 @@ export async function grok_login2(auth, username, password) {
             console.log('----');
             console.log(response.data);
 
-            var html = $('<html>').append(
-                $.parseHTML(response.data));
+            var parser = new DOMParser();
+            var doc = parser.parseFromString(
+                response.data, 'text/html');
 
-            var h1 = html.find('h1').html()
+            var h1 = doc.querySelectorAll(
+                'h1')[0].
+                innerHTML();
 
             if (h1.includes('Welcome back')) {
                 result['success'] = true;
             } else {
                 result['success'] = false;
 
-                var blockquote = html.find('blockquote').html();
+                var blockquote = doc.querySelectorAll(
+                    'blockquote'
+                )[0].innerHTML();
 
                 if (blockquote.includes('wrong password')) {
                     result['message'] = 'Wrong password.';