我正在学习如何编写chrome扩展,而且我对javascript很新.
这是一些HTML:
<div class="button data" style="">
<a class="button1 whiteColor" href="http://link1.com">VIEW This</a>
<a class="button2 redColor" href="http://link2.com">VIEW That</a>
</div>
Run Code Online (Sandbox Code Playgroud)
我想要做的是通过使用javascript自动点击button2打开link2.com.
我正在使用以下内容,但它不起作用:/
document.getElementByClassName("button2 redColor").click();
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激!!
html javascript google-chrome onclick google-chrome-extension
我目前正在构建一个谷歌扩展,这就是我想要的:
在awesome.page1.html上做一些事情,然后自动按下一页.加载新页面后,填写表单的文本字段.
我的问题是,即使我知道如何填写文本字段,我也不知道如何在page2加载后告诉它填写它.它一直试图在第1页上做所有事情.
这是我正在尝试但它不起作用:
function addEffect() {
document.getElementsByClassName("effect1 shine")[0].click();
document.getElementsByClassName("nextPage BigButton")[0].click();
nextStep();
}
function nextStep() {
if(document.getElementsByClassName("myformTextField imageName") != undefined) {
alert('Page 2 is up.');
}
else {
alert('Page 1 is still up.');
setTimeout("nextStep()", 250);
}
}
Run Code Online (Sandbox Code Playgroud)
我正在使用一个仅用于测试的警报,即使它仍然在第1页上,我仍然继续获得"Page 2已启动".我正在检查是否仅存在于第2页的元素是否已启动.我怎么能确定page2已启动?
我目前正在使用SLComposeViewController将用户的分数发布到twitter或facebook(取决于他们点击的按钮).当他们分享时,他们会获得虚拟货币奖励.我面临的问题是它只会告诉我用户是否点击发送或取消.如何检查推文是否实际发布到Twitter?这将有助于打击用户尝试两次提交相同推文的情况(twitter不允许).
这是我现在的代码:
//Check if user can send tweet
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) {
SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
tweetSheet.completionHandler = ^(SLComposeViewControllerResult result) {
switch(result) {
//This means the user cancelled without sending the Tweet
case SLComposeViewControllerResultCancelled:
NSLog(@"User Canceled");
break;
//This means the user hit 'Send'
case SLComposeViewControllerResultDone:
NSLog(@"User Tapped Send");
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
//Show alert & reward user here
break;
}
dispatch_async(dispatch_get_main_queue(), ^{
[self dismissViewControllerAnimated:NO completion:^{
NSLog(@"Tweet Sheet has been dismissed.");
}];
});
};
[tweetSheet setInitialText:[NSString stringWithFormat:@"Just scored …Run Code Online (Sandbox Code Playgroud) 我有一个没有标题的csv文件,我正在使用pandas导入到python中.最后一列是目标类,而其余列是图像的像素值.如何使用pandas(80/20)将此数据集拆分为训练集和测试集?
此外,一旦完成,我将如何分割每个集合,以便我可以定义x(除最后一列之外的所有列)和y(最后一列)?
我使用以下方法导入了我的文件:
dataset = pd.read_csv('example.csv', header=None, sep=',')
Run Code Online (Sandbox Code Playgroud)
谢谢
我知道存在关于同一问题的多个问题,但在遵循这个建议之后,我遇到了一些问题.
我已经完成了所有设置但每次使用kMTTimeZero时我都会遇到马赫错误.
soundQueue = [AVQueuePlayer queuePlayerWithItems:soundEmotions];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playerItemDidReachEnd:)
name:AVPlayerItemDidPlayToEndTimeNotification
object:[soundEmotions lastObject]];
Run Code Online (Sandbox Code Playgroud)
这就是我所做的.
- (void)playerItemDidReachEnd:(NSNotification *)notification {
// Do stuff here
NSLog(@"End has been reached.");
// Set it back to the beginning
[soundQueue seekToTime:kCMTimeZero];
//Replay
[soundQueue play];
}
Run Code Online (Sandbox Code Playgroud)
错误:架构armv7的未定义符号:"_kCMTimeZero",引用自: - ViewController中的[ViewController playerItemDidReachEnd:] ld:未找到架构armv7 clang的符号:错误:链接器命令失败,退出代码为1(使用 - v看看调用)
我正在使用Xcode 5.1.1和images.xcassets存储大量我的应用程序图像(我现在意识到,通过这样做,构建和运行我的应用程序将花费更长的时间)。任何人,一切都会按预期进行。当我通过设备连接并运行它时,所有图像都可以正常显示。
问题是,当我存档我的项目以发送给我的Beta测试人员时,通过这些方式进行安装后,该应用程序不会显示任何存储在images.xcassets中的图像,但是会出现其他正常存储的图像(图标存储在images.xcassets中的确出现)。
这有什么问题吗?
我有一个NSMutableAttributedString"timeString"我已经设置的字体和颜色.一切都很好,但我想知道是否有办法改变文本的高度而不改变文本的宽度(字体宽度= 100%,字体高度= 120%).
我尝试使用transform,但它不适用于NSMutableAttributedStrings.谢谢!
我已经想出了如何使用 PIL 检测图像中的边缘(图像主要是带有黑色绘图标记的白色背景)。如何检测包含这些边缘的矩形,以便裁剪图像。
例如,我想裁剪这样的东西:
进入:
或这个:
进入:
我熟悉 PIL 中的裁剪,但我不知道如何围绕对象自动居中。
我设法通过执行以下操作来检测边缘:
from PIL import Image, ImageFilter
image = Image.open("myImage.png")
image = image.filter(ImageFilter.FIND_EDGES)
Run Code Online (Sandbox Code Playgroud)
我如何获得包含所有这些边的矩形?
我正在显示自己的自定义提醒时,我正在向我的应用添加新的UIWindow.
在添加此UIWindow之前,我的应用程序隐藏了状态栏,但现在它可见.如何在这个新窗口中以编程方式隐藏状态栏.我已经尝试了一切,但它不起作用.
这就是我添加UIWindow的方式:
notificationWindow = [[UIWindow alloc] initWithFrame: CGRectMake(0, 0, 1.0, 1.0)];
notificationWindow.backgroundColor = [UIColor clearColor]; // your color if needed
notificationWindow.userInteractionEnabled = NO; // if needed
// IMPORTANT PART!
notificationWindow.windowLevel = UIWindowLevelAlert + 1;
notificationWindow.rootViewController = [UIViewController new];
notificationWindow.hidden = NO; // This is also important!
[notificationWindow addSubview:confettiView];
Run Code Online (Sandbox Code Playgroud) 我正在设置一个计时器,以便在第二次通过后我重置键盘扩展的值.问题是我觉得以下调用阻止了我的UI:
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[self resetDoubleTapBool];
})
Run Code Online (Sandbox Code Playgroud)
有一种异步方式可以做到这一点,或者更好的方式吗?谢谢!
multithreading objective-c grand-central-dispatch ios dispatch-async