八巷

文章 评论 浏览 28

八巷 2025-02-12 21:24:07

一些想法。

第一个 getElementById 可能会失败,因为该按钮可能尚不存在。

另外,仅搜索 #accept 可能不足以实际找到元素。这取决于您的页面的外观。

这是我要做的。在DevTools控制台中,请执行此操作:

document.getElementById('accept').length

如果它返回未定义,则您的CSS选择器不够具体。您可能必须再走一棵树 ……类似:

document.querySelector('body #main .prevDiv #accept')

你知道我的意思吗?从树上开始,然后走到元素。如果它在DevTools中不起作用,则在Tampermonkey中无法使用。在诸如Angular/React/Svelte/etc之类的现代库中,您可能拥有多个具有相同ID的元素...因此,指定单个元素可能找不到它。

然后,您的功能看起来像:

var checkTimer = setInterval(MyTimer, 1500);
checkTimer();

function MyTimer() {
   const eek = document.getElementById("accept");
   if (eek !== undefined){
      const evt = document.createEvent("MouseEvents");
      evt.initEvent("click", true, true);
      eek.dispatchEvent(evt);
   }
}

参考:

https://wwww.youtube.com/watch ?

​sowajlx1uka

A few thoughts.

The first getElementById will probably fail since that button likely does not exist yet.

Also, simply searching for #accept might not be enough to actually locate the element. It depends what your page looks like.

Here's what I do. In DevTools console, do this:

document.getElementById('accept').length

If it comes back undefined, then your css selector is not specific enough. You may have to walk the tree a bit more... something like:

document.querySelector('body #main .prevDiv #accept')

Do you know what I mean? Starting farther up the tree and walking down to the element. If it doesn't work in DevTools, it won't work in TamperMonkey. In modern libraries like Angular/React/Svelte/etc, you might have more than one element with the same ID... so just specifying the single element might not find it.

Then, your function can look like this:

var checkTimer = setInterval(MyTimer, 1500);
checkTimer();

function MyTimer() {
   const eek = document.getElementById("accept");
   if (eek !== undefined){
      const evt = document.createEvent("MouseEvents");
      evt.initEvent("click", true, true);
      eek.dispatchEvent(evt);
   }
}

References:

https://www.youtube.com/watch?v=Pr4LLrmDLLo

https://www.youtube.com/watch?v=SowaJlX1uKA

tampermonkey脚本检查按钮并单击它

八巷 2025-02-12 03:22:41

只需首先安装MUI基础即可。
如果您使用的是npm,请使用此命令:

npm install @mui/base

如果使用纱线,请使用此命令:

yarn add @mui/base

simply install the mui base first .
if you are using npm then go with this command :

npm install @mui/base

if you are using yarn then go with this command :

yarn add @mui/base

找不到模块:错误:可以分辨'@mui/base'

八巷 2025-02-12 02:29:02

您可以将全局变量用于该变量,也可以将变量存储在其他地方。我通常要做的是在基本目录中制作 config.py 文件,然后

放置config.py

money1 = 10

在代码中

import config

bint = 3
if config.money1 >= 3:
    config.money1 - bint
    await ctx.send(config.money1)

之类的变量。

try:
    client.money1
except:
    client.money1 = 10
...

You can use a global variable for that or store the variable somewhere else. What I usually do is make a config.py file in the base directory and then put variable there like

config.py

money1 = 10

in you code

import config

bint = 3
if config.money1 >= 3:
    config.money1 - bint
    await ctx.send(config.money1)

You can as well use your discord client (not recommend) like this:

try:
    client.money1
except:
    client.money1 = 10
...

如何确保保留数字的值?

八巷 2025-02-11 15:11:51

所有一旦遇到“假”对象,它将立即停止迭代。您可以使用一个简单的示例看到此内容:

def produce_numbers():
    for k in range(10):
        yield k
        print(k)

all(k < 3 for k in produce_numbers())

此打印

0
1
2

Python的文档。它指出以下是 all 的功能上等效的定义:

def all(iterable):
    for element in iterable:
        if not element:
            return False
    return True

all will stop the iteration as soon as it encounters a "falsey" object. You can see this with a simple example:

def produce_numbers():
    for k in range(10):
        yield k
        print(k)

all(k < 3 for k in produce_numbers())

This prints

0
1
2

This is spelled out in Python's documentation. It states that the following is a functionally equivalent definition of all:

def all(iterable):
    for element in iterable:
        if not element:
            return False
    return True

Python的内置&#x27; All&#x27;引擎盖下的功能工作?具体来说,找到第一个错误后会退出吗?

八巷 2025-02-11 13:41:04

您可以尝试以下尝试:

df = df.sort_values(by=['ID','SOURCE'])
df.loc[df['SOURCE'] == 'A','CNAME'] = df.NAME
df.CNAME = df['CNAME'].ffill()
df
索引 ID 名称 A
2 1 Axy A Axy
0 1 ABC B Axy
1 1 ABC C AXY
4 2 XYZ A XYZ
XYZ 3 2 XYZ B XYZ
7 3 SSA A SSA A SSA
6 3 SASA B SSA
8 3 SSA 8 3 SSA C SSA C SSA SSA C SSA
5 3 SASA D SSA
9 4 BVA A BVA
10 4 BA B BVA
11 5 NAS A NAS
12 5 VAN B NAS NAS NAS

You can try this:

df = df.sort_values(by=['ID','SOURCE'])
df.loc[df['SOURCE'] == 'A','CNAME'] = df.NAME
df.CNAME = df['CNAME'].ffill()
df
index ID NAME SOURCE CNAME
2 1 AXY A AXY
0 1 ABC B AXY
1 1 ABC C AXY
4 2 XYZ A XYZ
3 2 XYZ B XYZ
7 3 SSA A SSA
6 3 SASA B SSA
8 3 SSA C SSA
5 3 SASA D SSA
9 4 BVA A BVA
10 4 BA B BVA
11 5 NAS A NAS
12 5 VAN B NAS

基于组和条件的新列

八巷 2025-02-11 07:18:17

您需要更改循环“ //交换值”

// Swap the values
for (int i = 0; i < size; i++)
{
    sorted select = selection(nums, size, i);
    temp = nums[i];
    nums[i] = select.value;
    nums[select.index] = temp;
}

You need change loop "// Swap the values"

// Swap the values
for (int i = 0; i < size; i++)
{
    sorted select = selection(nums, size, i);
    temp = nums[i];
    nums[i] = select.value;
    nums[select.index] = temp;
}

函数在循环内部返回不正确的值(但外部正确值)

八巷 2025-02-10 18:58:22

您必须非常严格打开Excel对象并以 reververs 顺序结束它们 - 如本示例中所做的那样:

Public Sub RenameWorkSheet()

    Dim xls     As Excel.Application
    Dim wkb     As Excel.Workbook
    Dim wks     As Excel.Worksheet

    Set xls = New Excel.Application
    Set wkb = xls.Workbooks.Open("c:\test\workbook1.xlsx")
    Set wks = wkb.Worksheets(1)

    wks.Name = "My New Name"
    wkb.Close True

    Set wks = Nothing
    Set wkb = Nothing

    xls.Quit

    Set xls = Nothing

End Sub

You must be very strict in opening the Excel objects and closing them in reverse order - as done in this example:

Public Sub RenameWorkSheet()

    Dim xls     As Excel.Application
    Dim wkb     As Excel.Workbook
    Dim wks     As Excel.Worksheet

    Set xls = New Excel.Application
    Set wkb = xls.Workbooks.Open("c:\test\workbook1.xlsx")
    Set wks = wkb.Worksheets(1)

    wks.Name = "My New Name"
    wkb.Close True

    Set wks = Nothing
    Set wkb = Nothing

    xls.Quit

    Set xls = Nothing

End Sub

访问VBA-关闭Excel对象

八巷 2025-02-10 15:30:48

当该应用终止时,您无法打印任何内容,但是如果该应用程序在后台运行,则可以打印通知或通知其他数据。

在Android&gt;中添加notificationserviceextension.jave文件app&gt; src&gt; Main&gt; Kotlin&gt;在MainAttivity旁边

添加以下代码:

package your bundle_id;

import android.content.Context;
import android.util.Log;
import org.json.JSONObject;

import com.onesignal.OSNotification;
import com.onesignal.OSMutableNotification;
import com.onesignal.OSNotificationReceivedEvent;
import com.onesignal.OneSignal.OSRemoteNotificationReceivedHandler;



@SuppressWarnings("unused")
public class NotificationServiceExtension implements 
OSRemoteNotificationReceivedHandler {

@Override
public void remoteNotificationReceived(Context context, OSNotificationReceivedEvent notificationReceivedEvent) {
    OSNotification notification = notificationReceivedEvent.getNotification();
    Log.i("OneSignalExample", "Notification Data: " + notification);

    // Example of modifying the notification's accent color
    OSMutableNotification mutableNotification = notification.mutableCopy();
    mutableNotification.setExtender(builder -> {
        // Sets the accent color to Green on Android 5+ devices.

        //Force remove push from Notification Center after 30 seconds
        builder.setTimeoutAfter(30000);
        return builder;
    });
    JSONObject data = notification.getAdditionalData();
    //log.i will print data in body of notification
    Log.i("OneSignalExample", "Received Notification Data: " + data);
    
    // If complete isn't call within a time period of 25 seconds, 
    OneSignal internal logic will show the original notification
    // To omit displaying a notification, pass `null` to complete()
   


    notificationReceivedEvent.complete(mutableNotification);
   }
}

不要忘记在清单Android中的应用程序标签下方添加这些标签

<meta-data android:name="com.onesignal.NotificationServiceExtension"
               android:value="your_bundle_id.NotificationServiceExtension" />

when the app is terminated you can’t print anything but if the app is running in the background you can print notifications or notification additional data like this.

add NotificationServiceExtension.jave file in android > app > src > main > kotlin > next to mainActivity

add the following code:

package your bundle_id;

import android.content.Context;
import android.util.Log;
import org.json.JSONObject;

import com.onesignal.OSNotification;
import com.onesignal.OSMutableNotification;
import com.onesignal.OSNotificationReceivedEvent;
import com.onesignal.OneSignal.OSRemoteNotificationReceivedHandler;



@SuppressWarnings("unused")
public class NotificationServiceExtension implements 
OSRemoteNotificationReceivedHandler {

@Override
public void remoteNotificationReceived(Context context, OSNotificationReceivedEvent notificationReceivedEvent) {
    OSNotification notification = notificationReceivedEvent.getNotification();
    Log.i("OneSignalExample", "Notification Data: " + notification);

    // Example of modifying the notification's accent color
    OSMutableNotification mutableNotification = notification.mutableCopy();
    mutableNotification.setExtender(builder -> {
        // Sets the accent color to Green on Android 5+ devices.

        //Force remove push from Notification Center after 30 seconds
        builder.setTimeoutAfter(30000);
        return builder;
    });
    JSONObject data = notification.getAdditionalData();
    //log.i will print data in body of notification
    Log.i("OneSignalExample", "Received Notification Data: " + data);
    
    // If complete isn't call within a time period of 25 seconds, 
    OneSignal internal logic will show the original notification
    // To omit displaying a notification, pass `null` to complete()
   


    notificationReceivedEvent.complete(mutableNotification);
   }
}

don't forget to add these tags just below application tag in manifest android

<meta-data android:name="com.onesignal.NotificationServiceExtension"
               android:value="your_bundle_id.NotificationServiceExtension" />

remotenotificationReceivedHandler未设置,显示正常的信号通知颤动

八巷 2025-02-10 03:57:09

您可以尝试添加以下代码:

import "./main.css";

const h1 = document.createElement("h1");
h1.innerText = "Heading1";
document.body.append(h1);

if (module.hot) {
  module.hot.dispose(() => {
    document.body.innerHTML = "";
  });
  module.hot.accept();
}

module.hot.accept() will 接受自身的更新。

浏览器控制台中的HMR日志:

[HMR] Updated modules:
[HMR]  - ./src/index.js
[HMR] App is up to date.

You can try to add the following code:

import "./main.css";

const h1 = document.createElement("h1");
h1.innerText = "Heading1";
document.body.append(h1);

if (module.hot) {
  module.hot.dispose(() => {
    document.body.innerHTML = "";
  });
  module.hot.accept();
}

module.hot.accept() will accept updates for itself.

The HMR logs in browser console:

[HMR] Updated modules:
[HMR]  - ./src/index.js
[HMR] App is up to date.

热模块更换始终完整重新加载

八巷 2025-02-09 22:37:22
from sklearn.preprocessing import StandardScaler
df1 = StandardScaler().fit_transform(df)

会解决这个问题。

from sklearn.preprocessing import StandardScaler
df1 = StandardScaler().fit_transform(df)

Will do the trick.

如何将数据帧列转换为零均值和一个标准偏差

八巷 2025-02-09 20:18:11

这是学习如何调试的绝佳方法。

例外是在这一行上抛出的:

Color currentPixelColor = bitmap.GetPixel(x, y);

它明确指出了错误是在 y 上。如果将鼠标放在 y 上,您将看到 1080 (可能取决于屏幕分辨率),这实际上是在[0,1079中] 范围。

“但是我只是检查了它在之前的范围内……”

如果将鼠标放在 systemInformation.virtualscreen.height 上,您会看到,如预期的 1080 。但是,如果将鼠标放在&lt; 上,您会发现条件是 true 没有预期...

您将 1080 与什么?将鼠标放在变量上,您会看到... 0 。我们在那之前就看到了 y 1080 。然后,您会看到您的错字。在您的第二个循环中,您的条件检查 x 的值,而不是 y

因此,您只需要

for (int y = 0; x < SystemInformation.VirtualScreen.Height; y++)

替换

for (int y = 0; y < SystemInformation.VirtualScreen.Height; y++)

It's an excellent way to learn how to debug.

The exception is thrown on this line:

Color currentPixelColor = bitmap.GetPixel(x, y);

And it clearly states that the error is on y. If you put your mouse over the y, you'll see 1080 (probably, depending on your screen resolution), which is, indeed, out of the [0, 1079] range.

"But I just checked that it was within the range just before..."

If you put your mouse over SystemInformation.VirtualScreen.Height, you'll see, as expected 1080. But if you put your mouse over <, you'll see that the condition is true. That's not expected...

What are you comparing 1080 to? Put your mouse on the variable and you see... 0. And we saw just before that y was 1080. Then you'll see your typo. In your second for loop, your condition checks the value of x, instead of y.

So you just have to replace

for (int y = 0; x < SystemInformation.VirtualScreen.Height; y++)

with

for (int y = 0; y < SystemInformation.VirtualScreen.Height; y++)

C#检查屏幕上的颜色错误:参数必须为正面并且&lt;高度。 (参数&#x27; y&#x27;)

八巷 2025-02-09 06:30:56

我能够通过以下组合解决问题:

  • 封闭的Visual Studio
  • 删除 **/bin/** **/obj/**
  • 更新的Visual Visual最新版本的工作室
  • 删除了组件缓存:%userProfile%\ appdata \ local \ Microsoft \ Microsoft \ visualStudio \ 1x.0 \ componentModelCache
  • %userprofile%\ appdata \ local \ local \ local \ local \ local \ local \ local \ local \ local \ local \ local \ local \ local \ local \ local \ componentModelcache temp

Internets ,但我没有触摸它们:

%userProfile%\ AppData \ local \ Microsoft \ Team Foundation
%userProfile%\ appdata \ local \ Microsoft \ visualstudio
%userProfile%\ appdata \ local \ Microsoft \ vscommon

I was able to get rid of the issue through a combination of the following:

  • Closed Visual Studio
  • Removed **/bin/** **/obj/**
  • Updated Visual Studio to the latest version
  • Removed the component cache: %USERPROFILE%\AppData\Local\Microsoft\VisualStudio\1x.0\ComponentModelCache
  • Removed all temporary files in %USERPROFILE%\AppData\Local\Temp

Those locations are also mentioned on the internets, but I didn't touch them:

%USERPROFILE%\AppData\Local\Microsoft\Team Foundation
%USERPROFILE%\AppData\Local\Microsoft\VisualStudio
%USERPROFILE%\AppData\Local\Microsoft\VSCommon

Visual Studio 2022错误:Hresult的例外:0x800300FA(STG_E_ABNORMALAPIEXIT)

八巷 2025-02-08 16:19:57

您是否查看了 gatsby-plugin-plugin-asset-path ?它仅在您进行 gatsby build 时起作用。

Have you looked at gatsby-plugin-asset-path? It only works when you do a gatsby build though.

盖茨比:有什么方法可以在发展中的资产中添加前缀路径?

八巷 2025-02-08 13:14:58

您可以像这样返回ID值和购买值。

-- for returning single upgrade
module.getUpgrade = function(upgradeID)
    for i, upg in pairs(Upgrades) do
        if upg.id == upgradeID then
            return {id = upg.id, purchased = upg.purchased}
        else
            continue
        end
    end
    return nil
end
-- for multiple upgrades just loop through the table
module.getUpgrades = function()
    res = {}
    for i, v in pairs(Upgrades)do
       table.insert(res,{id = v.id, purchased = v.purchased})
    end
    return res
end

如果您知道自己在做什么,则可以忽略我的其余答案。

您需要调用modulename.getUpgrades()以保存。

local moduleName = require("YourModuleName")

-- To save, just call the function inside the setAsync
PlayerSavesU:SetAsync(player.UserId, moduleName.getUpgrades())

-- To use the retrieved data from GetAsync();
local data = PlayerSavesU:GetAsync(player.UserId);
if(data ~= nil) then
    for i,v in pairs(data) do
        print(v.id, v.purchased)
    end
end

虽然,此代码可能起作用。它仍然不是很有用,因为它不知道哪个玩家购买了这些物品。因此,您需要添加一种识别每个玩家的方法。

You can return the id value and purchased value like this.

-- for returning single upgrade
module.getUpgrade = function(upgradeID)
    for i, upg in pairs(Upgrades) do
        if upg.id == upgradeID then
            return {id = upg.id, purchased = upg.purchased}
        else
            continue
        end
    end
    return nil
end
-- for multiple upgrades just loop through the table
module.getUpgrades = function()
    res = {}
    for i, v in pairs(Upgrades)do
       table.insert(res,{id = v.id, purchased = v.purchased})
    end
    return res
end

If you know what you are doing, you can ignore the rest of my answer.

You need to call the moduleName.getUpgrades() for saving.

local moduleName = require("YourModuleName")

-- To save, just call the function inside the setAsync
PlayerSavesU:SetAsync(player.UserId, moduleName.getUpgrades())

-- To use the retrieved data from GetAsync();
local data = PlayerSavesU:GetAsync(player.UserId);
if(data ~= nil) then
    for i,v in pairs(data) do
        print(v.id, v.purchased)
    end
end

Although, this code might work. It is still not very useful because it does not know which player purchased the items. So you need to add a way to identify each player.

我如何将购买播放器的购买保存到数据存储?

八巷 2025-02-08 05:24:35

The following fix in jest.config.js no longer works from version 9.0.0 as they 删除束步

  ...
  moduleNameMapper: {
    'react-markdown': '<rootDir>/node_modules/react-markdown/react-markdown.min.js',
  },
  ...

The following fix in jest.config.js no longer works from version 9.0.0 as they remove the bundle step.

  ...
  moduleNameMapper: {
    'react-markdown': '<rootDir>/node_modules/react-markdown/react-markdown.min.js',
  },
  ...

开玩笑遇到了一个意外的令牌&#x2B; React Markdown

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文