有时在过载期间,某些站点无法加载.
我可以使用chrome.webRequest.onErrorOccurred api检测到这个错误.
我想在这种情况下内容脚本根本不会运行,因此从后台页面向内容脚本发送消息是没有用的.
如何在站点主体中粘贴无法加载的通知?
也许从后台页面使用脚本执行?页面是否有正文内容?
我只是想匹配“{”。但不知道为什么会出现这个错误:
Run Code Online (Sandbox Code Playgroud)terminate called after throwing an instance of 'std::regex_error' what(): regex_error Aborted (core dumped)
在 Ubuntu 上使用 g++ 版本 4.6.3 进行编译
g++ -std=c++0x a.c
Run Code Online (Sandbox Code Playgroud)
#include<iostream>
#include<regex>
using namespace std;
main(int argc,char**argv){
if (regex_match("{1}" , std::regex ("[{]"))) {
cout<<"Hello World"<<endl;
}
}
Run Code Online (Sandbox Code Playgroud)
我还检查了ECMAScript详细信息,这个正则表达式应该匹配。当我使用 like 时它也不匹配:std::regex ("\\{"))
我怎么了?
我想在页面加载时停止执行window.location,如下所示:
<script type="text/javascript">
alert('Bid closed ');
window.location = '/index.html';
</script>
Run Code Online (Sandbox Code Playgroud)
我可以alert通过在manifest.json中替换alert函数来绕过消息document_start.但无法阻止window.location执行.
当我访问此 URL 时清除浏览器历史记录后:http : //indianvisa-bangladesh.nic.in/visa/index.html
然后我点击“Get Appointment”绿色链接,将我们带到http://indianvisa-bangladesh.nic.in/visa/Appointment_Login.jsp
在这里它设置了一个JSESSIONIDcookie。我可以在 Firefox/Chrome 开发人员工具中看到此 cookie,但无法document.cookie在控制台中使用它访问它。
当我输入时,document.cookie;它显示空字符串。
如何打印?
编辑:此 JSESSIONID cookie 的Path值也为“/visa”
我想使用一些IDE,该IDE允许我即时更改javaScript代码并在浏览器中运行它。我认为我无法在Firebug中做到这一点。
我应该使用哪个IDE /软件进行JavaScript开发?
我能够以某种方式运行这个扩展:
https://github.com/mdn/webextensions-examples/tree/master/beastify
popup/choose_beast.js单击时会调用浏览器图标。
有人可以告诉我为什么这段代码(放置在顶部popup/choose_beast.js)会生成异常:
try{
var ss = require("sdk/simple-storage");
ss.storage.myArray = [1, 1, 2, 3, 5, 8, 13];
}catch(e){
alert('exception');
console.log(e);
}
Run Code Online (Sandbox Code Playgroud)
这是 中的相关条目manifest.json:
"browser_action": {
"default_icon": "icons/beasts-32.png",
"default_title": "Beastify",
"default_popup": "popup/choose_beast.html"
}
Run Code Online (Sandbox Code Playgroud)
我可以通过什么方式将数据存储在此弹出 html 中,以便我可以随时在内容脚本中检索?
另外,这个页面choose_beast.html是在什么上下文中运行的?背景、页面脚本还是内容脚本?
我有这个页面。我需要使用AngularJS触发单击此页面上的“立即购买”按钮。
我尝试了以下方法在内容脚本(myscript.js)中单击“立即购买”,但无法正常工作:
angular.element($('ul form button:contains("BUY NOW")').get(0)).triggerHandler('click');
$('ul form button:contains("BUY NOW")').get(0).click();
$('ul form button:contains("BUY NOW")').get(0).dispatchEvent(new MouseEvent('click', {
'view': window,
'bubbles': true,
'cancelable': true
}));
Run Code Online (Sandbox Code Playgroud)
manifest.json看起来像这样:
"content_scripts": [
{
"run_at": "document_end",
"all_frames": false,
"matches": ["*://www.flipkart.com/*"],
"css": [ "jqueryui/jquery-ui.css", "js/slidenavi/sidenavi-right.css","main.css", "js/bootstrap-switch-master/dist/css/bootstrap3/bootstrap-switch.min.css"],
"js": ["jquery-2.1.4.min.js", "jqueryui/jquery-ui.min.js","js/angular.min.js", "js/jquery.cookie.js", "jqueryui/jquery-ui.min.js","js/slidenavi/SideNavi.js", "client_server_common.js", "user-selections.js",
"jquery.countdown.min.js", "js/bootstrap-switch-master/dist/js/bootstrap-switch.min.js", "js/cryptojs/rollups/md5.js", "common.js",
"myscript.js"
]
}
],
Run Code Online (Sandbox Code Playgroud)
使它起作用的方法是什么?
最初我发布了这个问题.但随后我通过反复试验获得了答案.现在我想知道我的答案能起作用的原因.
在我从扩展程序运行时保存的页面中, $("#debitCard").change();它不起作用,但是当我从Chrome控制台运行时,它有效吗?
为什么这种行为可能与从Console运行时有所不同?我甚至在里面运行它setTimeout
我甚至在点击时在HTML中创建了一个按钮,它将调用此功能,但即使这样也无效.但是,每次从控制台调用都在工作.
回答
我把它换成 $("#debitCard").change(); 了这个:
var element = document.getElementById('debitCard');
var event = new Event('change');
element.dispatchEvent(event);
Run Code Online (Sandbox Code Playgroud)
我想知道这个Javascript/JQuery怪癖的原因
我有这个代码:
$("body").mousemove(function (event) {
var lowestspanelm = findNearestSpan(gg_phone_spans, event);
});
Run Code Online (Sandbox Code Playgroud)
在鼠标移动期间,这会生成太多事件并增加 CPU 负载,大约需要 1 分钟左右才能恢复正常。
为了减少这种负载,我想要的是仅在鼠标停止至少 1/2 秒时才进行操作。
有什么方法可以做到呢?
为什么这段代码打印51而不是26?我正试图提取"价值观".这就是我想要的(大胆的):<option value =" Andaman&Nicobar "> Andaman&Nicobar </ option>
根据定义m在列表上下文中使用g运算符应该在parantheses中返回模式?
my $firstpage=<<'EOF';
<option value="Andaman & Nicobar">Andaman & Nicobar</option>
<option value="Andhra Pradesh">Andhra Pradesh</option>
<option value="Assam">Assam</option>
<option value="Bihar">Bihar</option>
<option value="Calcutta Telecom District">Calcutta Telecom District</option>
<option value="Chennai Telecom District">Chennai Telecom District</option>
<option value="Chhattisgarh">Chhattisgarh</option>
<option value="Gujarat">Gujarat</option>
<option value="Haryana">Haryana</option>
<option value="Himachal Pradesh">Himachal Pradesh</option>
<option value="Jammu & Kashmir">Jammu & Kashmir</option>
<option value="Jharkhand">Jharkhand</option>
<option value="Karnataka">Karnataka</option>
<option value="Kerala">Kerala</option>
<option value="Madhya Pradesh">Madhya Pradesh</option>
<option value="Maharashtra">Maharashtra</option>
<option value="North East I">North East I</option>
<option value="North East II">North East II</option>
<option value="Orissa">Orissa</option>
<option …Run Code Online (Sandbox Code Playgroud) 我的兴趣是仅在重载时间处理网站,以便自动填充工作。例如,当销售开始并且网站蜂拥而至时,它有时会崩溃。我需要捕获站点错误,以便我可以从后台脚本重新加载页面。如Chrome 扩展:后台脚本捕获网络和 HTTP 错误中所述,我们可以获得页面加载错误。
页面加载错误可能是由于网络问题、站点问题、DNS 问题以及站点过载问题造成的。
我想要的只是重新加载网页,以防由于某些错误而未加载。
我为 Chrome 和 Firefox 收集了许多错误代码:
这不是完整列表。我见过这些错误,所以我列出了它们。我想知道当 (HTML) 页面无法加载时所有错误代码的列表,而不是使用反复试验找到它们。
这是我想如何使用的示例源代码:
chrome.webRequest.onErrorOccurred.addListener(function (details)
{
if ("type" in details && ['main_frame', 'sub_frame'].indexOf(details.type) == -1)
{
if (details.url.match(/.js$/))
{
console.log("Error in download of this file:", details.url);
}
return;
}
if (details.tabId == -1)
{
return;
}
var check_all_errors = function(err)
{
var all_errors = [
"net::ERR_ABORTED",
"net::ERR_EMPTY_RESPONSE",
"net::ERR_CONNECTION_TIMED_OUT",
"net::ERR_CONNECTION_REFUSED",
"net::ERR_CONNECTION_RESET",
"NS_ERROR_NET_ON_CONNECTING_TO",
'NS_ERROR_NET_ON_WAITING_FOR',
'NS_ERROR_NET_ON_CONNECTING_TO'
];
for( var i=0;i<all_errors.length;++i) …Run Code Online (Sandbox Code Playgroud) javascript google-chrome-extension firefox-addon-webextensions
为什么这个网址提取不起作用?
实际上这个 GET 方法正在传递一些要存储的错误消息:
fetch('http://www.govtschemes.in/pushlo90.php?msg=alert-bid:0.120148336001477231576473857578-Please%20enter%20correct%20captcha', {
method: 'get'
}).then(function(response) {
}).catch(function(err) {
// Error :(
});
Run Code Online (Sandbox Code Playgroud)
但是,如果我在浏览器中输入相同的 URL ( http://www.govtschemes.in/pushlo90.php?msg=alert-bid:0.120148336001477231576473857578-Please%20enter%20correct%20captcha ) 就可以了。
WebExension 中的其他一些地方工作正常。
但不在另一个地方工作。此外,当我也进入 Firefox 控制台时,它也不起作用。它显示了一些“待定..”
此函数也显示相同的行为:
function ff_httpGetAsync(theUrl, callback, failed_cb) {
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
// console.log("Successfully downloaded the ajax page");
if (callback) {
if (xmlHttp.responseURL == theUrl) {
callback(xmlHttp.response);
} else {
console.log("diff response url received" + xmlHttp.responseURL);
}
}
} else { …Run Code Online (Sandbox Code Playgroud)