यहाँ के लिए दो बार या अधिक पूर्ण स्थिति हो रही है मेरी स्क्रिप्ट है, जो प्रत्येक यूआरएल की जाँच करने के onUpdated.addListener का उपयोग करता है:chrome.tabs.onUpdated.addListener प्रत्येक पृष्ठ
chrome.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) {
alert(changeInfo.status);
if (changeInfo.status == 'complete') {
if (tab.url.indexOf("in.yahoo.mail") !== -1) {
alert(tab.url);
chrome.tabs.update(tabId, { url: "https://accounts.google.com/ServiceLogin" });
//injectToTab(tab);
}
}
});
और यहाँ प्रकट कोड है:
{
"name": "LeoPlugin For Test",
"version": "1.6",
"manifest_version": 2,
"content_security_policy": "script-src 'self'; object-src 'self'",
"description": "Extension to Automate.",
"background": {
"scripts": ["js/eventPage.js"],
"persistent": false
},
"content_scripts": [
{
"matches": ["http://*/*"],
"js": ["js/eventPage.js"]
}
],
"icons":{"48":"images/bob48.png", "128":"images/bob128.png"}, //Define any icon sizes and the files that you want to use with them. 48/128 etc.
"browser_action": {
"default_icon": "images/bob.png", // What icon do you want to display on the chrome toolbar
"default_popup": "testwatch.html" // The page to popup when button clicked.
},
"permissions": [
"tabs", "http://*/*","https://*/*" // Cross Site Access Requests
]
}
उपरोक्त कोड में कुछ भी गायब है जो एक से अधिक बार 'पूर्ण' स्थिति को रोकने से रोक सकता है।
<html>
<head>
<title>Leo Chrome Extension</title>
<link href="css/main.css" rel="stylesheet" type="text/css" />
<link href="css/fonts.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="jquery/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="jquery/jquery-ui-1.8.2.custom.min.js"></script>
<!--<script type="text/javascript" src="js/Pluginjshelper.js"></script>-->
</head>
<body class="inner_bg">
<div class="grey-panel">
<div>
<div class="user-pic">
<img src="Images/leo-logo.png" width="70" height="50" />
</div>
<h3>
Leo Extension</h3><input name="ok" type="button" class="btn" id = "button123" value="OK"/> <!--onclick = "getCPRepGraph()" -->
<input name="chkEnable" id="chkPluginEnable" type="checkbox" value="" class="check" /><span class="lbl">Enable</span>
</div>
<div class="clear">
</div>
<div>
<h4>
<span class="blue">Plugin </span>Credentials</h4>
<ul class="addpage-form2">
<li>
<label class="addpage-label">
User Name :</label><input name="txtUserName" id="txtUserName" type="text" class="addpage-input2" />
</li>
<li>
<label class="addpage-label">
Password :</label><input name="txtPassword" id="txtPassword" type="password" class="addpage-input2" />
</li>
</ul>
<div class="clear">
</div>
</div>
<!--BASIC INFO panel End-->
<div class="clear">
</div>
</div>
</body>
</html>
अपना समय के लिए अग्रिम धन्यवाद: और भी यहाँ मेरी एचटीएमएल कोड है।
आप क्या करना चाहते हैं? अद्यतन घटना पर या? – Sudarshan
इसे प्रत्येक आईफ्रेम के लिए ट्रिगर नहीं किया जा सकता है, 'chrome.tabs.onUpdated' टैब के लिए पृष्ठ नहीं है। तो यह प्रत्येक टैब के लिए केवल एक बार होता है। – ocanal
जब कोई नया टैब खोला जाता है, तो अद्यतित श्रोता पूर्ण रूप से दो बार स्थिति बदलता है। स्थिति अगर (changeInfo.status == 'पूर्ण') पृष्ठ के आधार पर दो या अधिक निष्पादित की जाएगी। उदाहरण के लिए, जब मैं Google होम पेज खोलता हूं, तो उसे दो बार पूर्ण स्थिति मिल जाएगी। मेरा सवाल यह है कि पूरी स्थिति को एक बार से अधिक बार बदलने या केवल एक बार स्थिति में स्क्रिप्ट निष्पादित करना बंद करना है। –