External Javascript file not being read by HTML in phone

I have a simple web app that is saved locally on my phone. Only 2 files, html and .js. The app works well locally on my computer but when I put the files on my phone and try it on google chrome the js does not work when is being called externally, i.e kept separately from the html but on the same folder. It only works when I embedd the js inside the html. I’m using android and google chrome.

Any help will be appreciated.

Electron desktop app works only on my dev pc but not on other pc

I have build my electron app using npm run electron-build . I got this .exe file from dist folder which I shared with my client but after he install the app his facing this error below on his pc.

Hasan Here Exam Portalresourcesappnode_modulesbetter-sqlite3buildReleasebetter_sqlite3.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 135. This version of Node.js requires
NODE_MODULE_VERSION 115. Please try re-compiling or re-installing
the module (for instance, using npm rebuild or npm install).

I am confused that why its working on my pc but not his the same app.

I tried npm rebuild but like I said it works on my pc but not his. I was expecting since it works on mine it should work on his pc too.

position: sticky / fixed seems not to work (React)

*sing position: sticky/fixed isn’t working on my navbar. I went through various questions here but didn’t work.

I even removed overflow property for the body.
I tried using position sticky and fixed for other elements too and it doesn’t work either.

Can u specify the probable issue here like any property that contradicts position sticky and fixed??

I’m trying to scrape a web page but keep getting back encrypted HTML and the JS file is obfuscated too [closed]

So I am learning how to scrape web pages right now in python. First I tried beautiful soup and now selenium webdriver.

I am trying to scrape some crossword puzzle clues from some crossword website but whenever I scrape the page, the puzzle data part of the html code is encrypted. It looks like this:

boatload_puzzles_puz_num=17573;
boatload_puzzles_puz_data='F5955C88A2E68B4CF2143A30085A02BC0CD93EBC23363509A09749D79C4DE80C'
  + '88F9828CB7570B90F73D72AC773FAFA36B6EB87BDDC7EF12669BF8C4BEFA0C98'
  + '18DE48510139817914FD14EF5793DC6E00488A4CB5FF22A2A542D5DF0FF35D07'
  + 'A93FD6A2E3CFEF30CACAB964A27B08573DB7A6D430F233DD070CA17AA3715356'
  + '6A3D8EA8E8C3BEAADAEADA6ED1CF156CA0083B55780ED57406F391F443D80AFB'
  + '7B38F201495C80713D07DD04D453C1CDA26BCF3EEB54B8CDBBAF40AB15E38E9E'
  + '6E659CB7D50245E53880DD6B23B25DBA04339769C824FF26B705297DFD31139A'
  + '516662DF70A133F0A996EC86AFC59C4848A3FF32D17AD1344F6388DC0D952A79'
  + '100473B0DCF66A585EC0D9BC963F263B3F01496B96D93CCAE3BCF220E857BEA6'
  + '36320A36D6ED7DC710572411E7B6A5B3493C409270B6D26B50D3E4A8E95B71AD'
  + '7362C75FEB1238857512FED16758548ABDD1AD8A42AFF8A841A34FD9A88FEE56'
  + '84AE28E3D5B9291224425D28B6564792E0A908310CFD556539144E5E9FF09BDD'
  + '36B237B4E7BE5DBDD6CD341E3F876242DCBD2B4313459CF77D961284ABEDAE6D'
  + '25C12264FF1D864218DA2512FE7C42A6AF262A64C044C3D2BB960137C4F42EEC'
  + 'D42B539DCEA7721EB0ED39CBF52F4AA0D1587D4561077D16485EF90CB700ED06'
  + '1B2030C37455031CFEE229A805411FCE86302C94454E4270AAFBED4D5F309865'
  + '7218CDE64132FA5E1169E32A3123E9140D089DA66C40D9958C44C0C573B464C6'
  + '20263ACAFD614F43B269779983BA744BE1B05E863935E1389B72A9C043999267'
  + 'FEC371761534DD67C41E3835C28CB9E651ADCD9E5EE4C790F84295A21E919AD1'
  + '03470BD11502C51DAC506999CFEA9B53B1ABDBA319F38C8B4A3D06E53BC96AC9'
  + 'CBD3664A11B0216A1F1B6C3041B2877BCCA4216CB1FC823BABABD8D35D455794'
  + 'C1D7494FEBC9B3192E76A8A0D6C41417F9E2D72F462AD41EF262829E29B3B594'
  + '153B8505A8006468A0CEE7870DF89C4C1601370770915AC9061DF24C4711C806'
  + '20DCFE17F482047EE7EA1BB71524B804C8AEB341D5F66FCE54E504BA7E960DB7'
  + '1FE5B219677411C44734374C805B945F69E7AE98DB2AEA4CF67D9B1A4C36FB36'
  + '37B42A1BC3DB1A8E66A453A4374EF83313EFEDB0168CA29AD9D434BDF4B4B940'
  + '10BBF3365D0E1754B7DCBDC6520E60A6B21F1EB9EF67C33C1FB8E1A1CA9060FE'
  + 'D2E5E16C39F97E791C99719589B573D7AFADA2AD0A0533A19D06BBD3CDAD7CDF'
  + '52897281CED8A1764B748BE7785B3859B65182D056E651C739A1028B7AE66C3D'
  + '004CC274DE6F93AFA7D979249742C95A7BA04092';
boatload_puzzles_key='2401B369A829B52C8F556227236EDAEC';

The weird thing is that when I inspect the elements on the actual web page I can see the puzzle clues and data just fine.

Lastly, I tried looking into the pages js file to find some decryption logic but it is super obfuscated and looks crazy. I don’t even know javascript so this is a bit over my head.

I appreciate any help I can get!

I’m trying to scrape a web page but keep getting back encrypted HTML and the JS file is obfuscated too

So I am learning how to scrape web pages right now in python. First I tried beautiful soup and now selenium webdriver.

I am trying to scrape some crossword puzzle clues from some crossword website but whenever I scrape the page, the puzzle data part of the html code is encrypted. It looks like this:

boatload_puzzles_puz_num=17573;
boatload_puzzles_puz_data='F5955C88A2E68B4CF2143A30085A02BC0CD93EBC23363509A09749D79C4DE80C'
  + '88F9828CB7570B90F73D72AC773FAFA36B6EB87BDDC7EF12669BF8C4BEFA0C98'
  + '18DE48510139817914FD14EF5793DC6E00488A4CB5FF22A2A542D5DF0FF35D07'
  + 'A93FD6A2E3CFEF30CACAB964A27B08573DB7A6D430F233DD070CA17AA3715356'
  + '6A3D8EA8E8C3BEAADAEADA6ED1CF156CA0083B55780ED57406F391F443D80AFB'
  + '7B38F201495C80713D07DD04D453C1CDA26BCF3EEB54B8CDBBAF40AB15E38E9E'
  + '6E659CB7D50245E53880DD6B23B25DBA04339769C824FF26B705297DFD31139A'
  + '516662DF70A133F0A996EC86AFC59C4848A3FF32D17AD1344F6388DC0D952A79'
  + '100473B0DCF66A585EC0D9BC963F263B3F01496B96D93CCAE3BCF220E857BEA6'
  + '36320A36D6ED7DC710572411E7B6A5B3493C409270B6D26B50D3E4A8E95B71AD'
  + '7362C75FEB1238857512FED16758548ABDD1AD8A42AFF8A841A34FD9A88FEE56'
  + '84AE28E3D5B9291224425D28B6564792E0A908310CFD556539144E5E9FF09BDD'
  + '36B237B4E7BE5DBDD6CD341E3F876242DCBD2B4313459CF77D961284ABEDAE6D'
  + '25C12264FF1D864218DA2512FE7C42A6AF262A64C044C3D2BB960137C4F42EEC'
  + 'D42B539DCEA7721EB0ED39CBF52F4AA0D1587D4561077D16485EF90CB700ED06'
  + '1B2030C37455031CFEE229A805411FCE86302C94454E4270AAFBED4D5F309865'
  + '7218CDE64132FA5E1169E32A3123E9140D089DA66C40D9958C44C0C573B464C6'
  + '20263ACAFD614F43B269779983BA744BE1B05E863935E1389B72A9C043999267'
  + 'FEC371761534DD67C41E3835C28CB9E651ADCD9E5EE4C790F84295A21E919AD1'
  + '03470BD11502C51DAC506999CFEA9B53B1ABDBA319F38C8B4A3D06E53BC96AC9'
  + 'CBD3664A11B0216A1F1B6C3041B2877BCCA4216CB1FC823BABABD8D35D455794'
  + 'C1D7494FEBC9B3192E76A8A0D6C41417F9E2D72F462AD41EF262829E29B3B594'
  + '153B8505A8006468A0CEE7870DF89C4C1601370770915AC9061DF24C4711C806'
  + '20DCFE17F482047EE7EA1BB71524B804C8AEB341D5F66FCE54E504BA7E960DB7'
  + '1FE5B219677411C44734374C805B945F69E7AE98DB2AEA4CF67D9B1A4C36FB36'
  + '37B42A1BC3DB1A8E66A453A4374EF83313EFEDB0168CA29AD9D434BDF4B4B940'
  + '10BBF3365D0E1754B7DCBDC6520E60A6B21F1EB9EF67C33C1FB8E1A1CA9060FE'
  + 'D2E5E16C39F97E791C99719589B573D7AFADA2AD0A0533A19D06BBD3CDAD7CDF'
  + '52897281CED8A1764B748BE7785B3859B65182D056E651C739A1028B7AE66C3D'
  + '004CC274DE6F93AFA7D979249742C95A7BA04092';
boatload_puzzles_key='2401B369A829B52C8F556227236EDAEC';

The weird thing is that when I inspect the elements on the actual web page I can see the puzzle clues and data just fine.

Lastly, I tried looking into the pages js file to find some decryption logic but it is super obfuscated and looks crazy. I don’t even know javascript so this is a bit over my head.

I appreciate any help I can get!

Clear Credit loan app CUSTOMER. care. helpline. NUMBER -)8126895445-//-91_/812-6895-445-Call ·

Clear Credit loan app CUSTOMER. care. helpline. NUMBER -)8126895445-//-91_/812-6895-445-Call ·Clear Credit loan app CUSTOMER. care. helpline. NUMBER -)8126895445-//-91_/812-6895-445-Call ·Clear Credit loan app CUSTOMER. care. helpline. NUMBER -)8126895445-//-91_/812-6895-445-Call ·Clear Credit loan app CUSTOMER. care. helpline. NUMBER -)8126895445-//-91_/812-6895-445-Call ·Clear Credit loan app CUSTOMER. care. helpline. NUMBER -)8126895445-//-91_/812-6895-445-Call ·Clear Credit loan app CUSTOMER. care. helpline. NUMBER -)8126895445-//-91_/812-6895-445-Call ·

AG Grid: How to Disable Caching and Fetch Group Parent Rows on Every Page Change

I’m using AG Grid with the server-side row model, along with pagination and row grouping.

Playground – https://plnkr.co/edit/VRqkoRfryOeoJgVl?open=index.jsx&preview

I want the grid to fetch data from the API every time I switch pages, instead of using cached data. In each page, I want to show 2 records, so I’m using the following config

rowModelType={'serverSide'}
pagination={true}
paginationPageSize={2}
cacheBlockSize={2}
maxBlocksInCache={1}

From what I understand:

  • Each cache block will contain 2 rows.
  • maxBlocksInCache is set to 1, so only the current page should be cached.

However, when I switch pages, the getRows method is only called for child rows (i.e., the inner rows of each group), not for the grouped/parent rows (like “United States”, “China”, etc.).

What I want is:

On every page change, data should be fetched from the server (no caching).
First, the grouped rows (e.g., “United States”, “China”) should be loaded/refetched.
Then, the child rows for each group should be fetched as needed.

Writing data to a child node in Firestore

When working with ‘firebase/firestore’ in a React app. I can sucessfully use code like the one below:

import {collection,addDoc,...} from 'firebase/firestore'

const collectionName = 'France',
      collectionRef = collection(fireStoreDB,collectionName),
      newRcd = await addDoc(collectionRef, {
        sentence: 'To be or not to be ...',
        chapter: 'chapterOne',
        order: 97
      })

But here is what I would like to do:

const collectionName = 'France/chapterOne',
      collectionRef = collection(fireStoreDB,collectionName),
      newRcd = await addDoc(collectionRef, {
        sentence: 'To be or not to be ...',
        order: 97
      })

Nevertheless, this last piece does not work at this point.
What do I need to modify in the code to make it work ?

How to encrypt file with ClearKey for Encrypted Media Extensions API?

I am playing around with the Encrypted Media Extensions API a bit and wondering about ClearKey encryption. As I understand it, the target file, or segments of it are encrypted using a symmetric key algorithm, and then that same key is also transmitted to the client as well. The client will then use this key to decrypt the content for playing with the EME API.

My question is this – will encrypting a video file (arraybuffer/bytes?) with a symmetric key be enough to satisfy the EME API and play the video with the associated key?

I am not sure ClearKey is that simple, or if I’m missing something else that needs to be done in the encryption process.

I understand there are options to output the desired result using existing tools like ffmpeg, etc. I’m wondering about creating these files programmatically without dependencies.

Is a db connection pool necessary in Node.js if await is non-blocking and libuv handles I/O?

I’m building a Node.js backend and trying to understand the role of database connection pooling more deeply.

Since Node.js is single-threaded and uses an event loop with non-blocking I/O via libuv, I figured that await would allow the app to handle thousands of concurrent requests without blocking. I understand that when await is hit (e.g., await db.query(…)), the query is offloaded to the underlying TCP/network layer, and Node can move on to handle other events or requests.

If the DB query is offloaded and non-blocking, and Node resumes the function only when the result comes back, why do I still need a pool of DB connections?

Wouldn’t a single connection be enough since the app is async and the queries are not blocking the event loop?

Here’s what I’m using as an example:

app.get('/price', async (req, res) => {
 const result = await db.query('SELECT price FROM crypto WHERE id = $1', [req.params.id]);
});

I’m using PostgreSQL with the pg library.
I’m debating whether to use a single Client or a Pool for handling queries.

Save a user in an array in a POST request [closed]

I’m new to back-end development. I’m doing the FCC back-end challenge, and I’m having a problem because they’re asking me to return an array in a GET request that contains all the existing users. But when I send it, the array always shows up empty, even though it was modified by the POST request. I don’t understand why it’s not working, and I would really appreciate it if someone could help me.

require('dotenv').config();
console.log(process.env.MONGO);
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const cors = require('cors');
const mongoose = require('mongoose');
const array = [];
//Connection to the DB
mongoose.connect(process.env.MONGO)
  .then(() => console.log("DB connected!"))
  .catch(err => console.error("error connecting to mongo", err));
app.use(cors())
app.use(express.static('public'))

app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())

app.get('/', (req, res) => {
  res.sendFile(__dirname + '/views/index.html')
});

//Schema of users
var userSchema = new mongoose.Schema({
  username: {
    type: String,
    require: true
  },
  description: {
    type: String,
    require: false
  },
  duration: {
    type: Number,
    require: false
  },
  date: {
    type: Date,
    require: false
  },

});
var user = mongoose.model('user', userSchema);



app.post('/api/users', async function (req, res) {
  var _name = req.body.username;
  var newUser = new user({ username: _name });
  await newUser.save(newUser);//save the new user in the DB
  //find the new user
  array.push(newUser);
  res.json(array[array.length-1]);
  
})


app.get('/api/users', async function (req, res) {
  res.json(array);
})


const listener = app.listen(process.env.PORT || 3000, () => {
  console.log('Your app is listening on port ' + listener.address().port)
})

Local override equivalent as a chrome extension (mv3)

I noticed you can use local overrides in devtools, allowing you to edit a site’s js content. I tried everything I could think of to replicate this as an extension, but I either got CSP blocked (Can’t override this), or ended up in a race condition of some sort.

I’d need to change a string in a loaded js chunk (nextjs) to another string.

Here’s my attempt (doesnt work):

(() => {

  const targetPatterns = [
    "foo"
  ];
  const replacement = "bar";

  const isBad  = str => targetPatterns.some(tp => str.includes(tp));
  const fixStr = str => (
    targetPatterns.reduce((s, tp) => s.replaceAll(tp, replacement), str)
  );

  function patchExports(obj) {
    if (!obj) return;
    if (typeof obj === "string" && isBad(obj)) return fixStr(obj);

    if (typeof obj === "object") {
      for (const k of Object.keys(obj)) {
        if (typeof obj[k] === "string" && isBad(obj[k])) {
          obj[k] = fixStr(obj[k]);
        }
      }
    }
  }

  function patchExecutedModules() {
    if (typeof __webpack_require__ !== "function" ||
        !__webpack_require__.c) return;

    const cache = __webpack_require__.c;
    let hit = 0;
    for (const id in cache) {
      if (patchExports(cache[id].exports)) hit++;
    }
    console.log(`[patcher] scrubbed ${hit} executed module(s)`);
  }

  function scanChunk(chunk) {
    const modules = chunk[1] || {};
    for (const id in modules) {
      const factory = modules[id];
      if (typeof factory !== "function") continue;

      const src = factory.toString();
      if (!isBad(src)) continue;

      const orig = factory;
      modules[id] = function (module, exports, require) {
        orig(module, exports, require);
        patchExports(exports);
      };
      console.log(`[patcher] wrapped module ${id}`);
    }
  }

  function hookArray(arr, name) {
    if (arr.__patched) return;
    arr.__patched = true;

    const origPush = arr.push.bind(arr);
    arr.push = function (chunk) { scanChunk(chunk); return origPush(chunk); };
    arr.forEach(scanChunk);
    console.log(`[patcher] hooked ${name} (had ${arr.length} chunk(s))`);
  }

  function tryHook() {
    const nativePush = Array.prototype.push;
    for (const k of Object.keys(window)) {
      const v = window[k];
      if (Array.isArray(v) && typeof v.push === "function" && v.push !== nativePush) {
        hookArray(v, k);
        return true;
      }
    }
    return false;
  }

  patchExecutedModules();
  (function wait() {
    if (!tryHook()) setTimeout(wait, 25);
  })();
})();

“select2 is not a function” or “.mask is not a function” errors when navigating between pages with Laravel Livewire + Turbo?

I’m using Laravel + Livewire + Turbo + Blade application.

Sometimes, when navigating to another page in the system, I get console errors like:

  • Uncaught TypeError: $(...).select2 is not a function jquery-3.6.0.min.js
  • Uncaught TypeError: $(...).mask is not a function pages.js

This doesn’t happen on first page load — only when navigating to another page, and it doesn’t always happen consistently.

I already include my JS libraries like this in the app.blade.php:

@livewireStyles
<script src="{{asset('assets/js/livewire-turbo.js') }}" data-turbolinks-eval="false" data-turbo-eval="false"></script>
@livewireScripts

<script src="//cdn.jsdelivr.net/npm/chart.js"></script>
<script src="{{ asset('assets/js/third-party.js') }}"></script>
{{-- <script src="{{ mix('js/front-third-party.js') }}"></script> --}}

<script src="{{ asset('messages.js') }}"></script>
{{-- <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> --}}
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/select2.min.js"></script>

<script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
<script src="https://cdn.jsdelivr.net/npm/flatpickr/dist/l10n/pt.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-daterangepicker/3.0.5/daterangepicker.min.js" integrity="sha512-mh+AjlD3nxImTUGisMpHXW03gE6F4WdQyvuFRkjecwuWLwD2yCijw4tKA3NsEFpA1C3neiKhGXPSIGSfCYPMlQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

{{-- <script src="{{ mix('js/pages.js') }}"></script> --}}
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.10/clipboard.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.16/jquery.mask.min.js"></script>


<script src="{{ mix('js/pages.js') }}"></script>

Get value and stop JS execution

I want to get a value that is generated by JavaScript code and is available in the HTTP header of a request. Then I want to continue with that webClient as it has cookies and resources loaded. I don’t know what the best practice is to stop the whole execution of JavaScript and have it ready afterwards. If I don’t stop it, the JavaScript of the page keeps going, even though I have no use for it. I know of webClient.waitForBackgroundJavaScript(), but that would keep going until the timeout is over. However, I only want the value and from what I can tell the order of the Ajax calls are rather random and have no timing for it. So I really have to wait for the value to appear.

This is my code so far:

public String getValueFromWeb throws Exception {
  BlockingQueue<String> valueCatcher = new ArrayBlockingQueue<>(1);
  WebClient webClient = new WebClient();
  WebConnection webConnection = webClient.getWebConnection();
  webClient.setWebConnection(new WebConnection() {
  
    @Override
    public WebResponse getResponse(WebRequest request) throws IOException {
      if (...) {                                                     // (2)
        valueCatcher.add("<grabbed value>");
        webClient.getJavaScriptEngine().shutdown();
      }
  
      return webConnection.getResponse(request);
    }
  
    @Override
    public void close() throws IOException {
      webConnection.close();
    }
  
  });
  
  Page page = webClient.getPage(...);
  
  String result = valueCatcher.take();                               // (1)
  webClient.setJavaScriptEngine(new JavaScriptEngine(webClient));
  
  // do another webClient.getPage(...)
  ...
}

So the execution of Java “pauses” at (1). At (2) I check if I’m at the right request and send the value back to (1). The JS engine should be restarted and ready to continue.

Does anyone have a better approach? Or maybe I’m missing something?

Using ExtendScript for Photoshop, is there a more elegant way of toggling a brush’s blend mode than this?

I could say that I got my money’s worth here, using two LLMs to put together a script in ExtendScript which switches the brush’s blend mode from Normal to Multiply and back again. I always wanted to learn more about programmatically extending Photoshop but never had a use for that, up until now.
I wonder: is this in general what LLMs do, creating code hard to understand by me, a layman, or is this output just the way ExtendScript looks like when applied to Photoshop’s engine?
The code below. I am curious: how good is this code at all? Does it rank at all, as anything? I sort of expect a lot of this code to be redundant, as well as having code which does not do anything, but I am nowhere educated enough to even guess.

function toggleBrushBlendMode() {
    try {
        // Reference the brush tool options
        var ref = new ActionReference();
        ref.putProperty(charIDToTypeID("Prpr"), stringIDToTypeID("tool"));
        ref.putEnumerated(charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));

        var toolDesc = executeActionGet(ref);
        if (!toolDesc.hasKey(stringIDToTypeID("currentToolOptions"))) {
            throw new Error("No currentToolOptions found.");
        }

        var options = toolDesc.getObjectValue(stringIDToTypeID("currentToolOptions"));
        var currentBlendMode = options.getEnumerationValue(stringIDToTypeID("mode"));
        var currentModeStr = typeIDToStringID(currentBlendMode);

        // Decide on the new mode
        var newMode = (currentModeStr === "normal") ? "multiply" : "normal";

        // Set the brush tool options with new blend mode
        var desc = new ActionDescriptor();
        var toolRef = new ActionReference();
        toolRef.putClass(stringIDToTypeID("paintbrushTool"));
        desc.putReference(charIDToTypeID("null"), toolRef);

        var optionsDesc = new ActionDescriptor();
        optionsDesc.putEnumerated(stringIDToTypeID("mode"), stringIDToTypeID("blendMode"), stringIDToTypeID(newMode));
        desc.putObject(charIDToTypeID("T   "), stringIDToTypeID("paintbrushTool"), optionsDesc);

        executeAction(charIDToTypeID("setd"), desc, DialogModes.NO);
    } catch (e) {
        alert("Error: " + e.message);
    }
}

toggleBrushBlendMode();

What do you think? Is this good enough for a blend mode switch?

I used ChatGPT and Copilot in a sort of back and forth between them, because each single output simply by itself did not work. I was feeding their output back to them, to hopefully get closer to a solution for my actually small problem: I wanted to be able to switch between blend modes at the push of a button.
I expected the script to be a lot shorter than it turned out to be, to be honest, and I expected it to be more easily readable than it is now, if you know what I mean.