onDownload
_script.getThreads().getMain().setBackground(true)
_webResources.afterDownload { webResource, scriptFile, throwable ->
if (scriptFile != null) {
_console.log("afterDownload", webResource, "下载成功", scriptFile)
} else if (throwable != null) {
_console.log("afterDownload", webResource, "下载失败", throwable)
}
}
var t = _dateTimes.getTimestamp()
_webResources.onDownload { webResource, progress ->
val nt = _dateTimes.getTimestamp()
// 防止是输出信息太多, 所以添加1s间隔
if (nt - t > 1000) {
_console.log("onDownload", webResource, progress)
t = nt
}
}
_webResources.beforeDownload { webResource ->
webResource.setUrl(webResource.getUrl().replace("172.16.0.238", "172.16.0.235"))
_console.log("beforeDownload", webResource)
null
}
$script.getThreads().getMain().setBackground(true)
$webResources.afterDownload { webResource, scriptFile, throwable ->
if (scriptFile != null) {
$console.log("afterDownload", webResource, "下载成功", scriptFile)
} else if (throwable != null) {
$console.log("afterDownload", webResource, "下载失败", throwable)
}
}
def t = $dateTimes.getTimestamp()
$webResources.onDownload { webResource, progress ->
def nt = $dateTimes.getTimestamp()
// 防止是输出信息太多, 所以添加1s间隔
if (nt - t > 1000) {
$console.log("onDownload", webResource, progress)
t = nt
}
}
$webResources.beforeDownload { webResource ->
webResource.setUrl(webResource.getUrl().replace("172.16.0.238", "172.16.0.235"))
$console.log("beforeDownload", webResource)
null
}
$script.getThreads().getMain().setBackground(true)
$webResources.afterDownload((webResource, scriptFile, throwable) => {
if (scriptFile != null) {
$console.log("afterDownload", webResource, "下载成功", scriptFile)
} else if (throwable != null) {
$console.log("afterDownload", webResource, "下载失败", throwable)
}
})
let t = $dateTimes.getTimestamp()
$webResources.onDownload((webResource, progress) => {
let nt = $dateTimes.getTimestamp()
// 防止是输出信息太多, 所以添加1s间隔
if (nt - t > 1000) {
$console.log("onDownload", webResource, progress)
t = nt
}
})
$webResources.beforeDownload((webResource) => {
webResource.setUrl(webResource.getUrl().replace("172.16.0.238", "172.16.0.235"))
$console.log("beforeDownload", webResource)
return null
})
_script:getThreads():getMain():setBackground(true)
_webResources:afterDownload(function(webResource, scriptFile, throwable)
if (scriptFile ~= nil) then
_console:log("afterDownload", webResource, "下载成功", scriptFile)
elseif (throwable ~= null) then
_console:log("afterDownload", webResource, "下载失败", throwable)
end
end)
local t = _dateTimes:getTimestamp()
_webResources:onDownload(function(webResource, progress)
local nt = _dateTimes:getTimestamp()
-- 防止是输出信息太多, 所以添加1s间隔
if (nt - t > 1000) then
_console:log("onDownload", webResource, progress)
t = nt
end
end)
_webResources:beforeDownload(function(webResource)
local RegexUtils = _java:loadClass("com.blankj.utilcode.util.RegexUtils")
webResource:setUrl(RegexUtils:getReplaceFirst(webResource:getUrl(), "172.16.0.238", "172.16.0.235"))
_console:log("beforeDownload", webResource)
return nil
end)
<?php
$script->getThreads()->getMain()->setBackground(true);
$webResources->afterDownload(function ($webResource, $scriptFile, $throwable) use ($console) {
if ($scriptFile != null) {
$console->log("afterDownload", $webResource, "下载成功", $scriptFile);
} else if ($throwable != null) {
$console->log("afterDownload", $webResource, "下载失败", $throwable);
}
});
$t = $dateTimes->getTimestamp();
$webResources->onDownload(function ($webResource, $progress) use ($dateTimes, &$t, $console) {
$nt = $dateTimes->getTimestamp();
// 防止是输出信息太多, 所以添加1s间隔
if ($nt - $t > 1000) {
$console->log("onDownload", $webResource, $progress);
$t = $nt;
}
});
$webResources->beforeDownload(function ($webResource) use ($plugins, $console) {
$RegexUtils = java_class("com.blankj.utilcode.util.RegexUtils");
$webResource->setUrl($RegexUtils->getReplaceFirst($webResource->getUrl(), "172.16.0.238", "172.16.0.235"));
$console->log("beforeDownload", $webResource);
return null;
});
_script.getThreads().getMain().setBackground(True)
def fn1(webResource, scriptFile, throwable):
if scriptFile != None:
_console.log("afterDownload", webResource, "下载成功", scriptFile)
elif throwable != None:
_console.log("afterDownload", webResource, "下载失败", throwable)
_webResources.afterDownload(fn1)
t = _dateTimes.getTimestamp()
def fn2(webResource, progress):
global t
nt = _dateTimes.getTimestamp()
# 防止是输出信息太多, 所以添加1s间隔
if nt - t > 1000:
_console.log("onDownload", webResource, progress)
t = nt
_webResources.onDownload(fn2)
def fn3(webResource):
webResource.setUrl(webResource.getUrl().replace("172.16.0.238", "172.16.0.235"))
_console.log("beforeDownload", webResource)
return None
_webResources.beforeDownload(fn3)
# encoding: utf-8
$script.getThreads().getMain().setBackground(true)
$webResources.afterDownload { |webResource, scriptFile, throwable|
if scriptFile != nil
$console.log("afterDownload", webResource, "下载成功", scriptFile)
elsif throwable != nil
$console.log("afterDownload", webResource, "下载失败", throwable)
end
}
t = $dateTimes.getTimestamp()
$webResources.onDownload { |webResource, progress|
nt = $dateTimes.getTimestamp()
# 防止是输出信息太多, 所以添加1s间隔
if nt - t > 1000
$console.log("onDownload", webResource, progress)
t = nt
end
}
$webResources.beforeDownload { |webResource|
java_import "com.blankj.utilcode.util.RegexUtils"
webResource.setUrl(RegexUtils.getReplaceFirst(webResource.getUrl(), "172.16.0.238", "172.16.0.235"))
$console.log("beforeDownload", webResource)
nil
}
Last modified: 29 April 2025