我想使用javascript/jquery在页面加载完成时触发一个事件.
页面加载完全完成后,有没有办法触发事件或调用简单函数.
如果你有任何参考,请建议大家.
我想从中获取一个值https://play.google.com/store/account*,这使得用户页面通过其输出.例如:
/store/account?start=0&num=40,然后/store/account?start=40&num=40,等等.
现在,当我访问时https://play.google.com/apps,我希望Greasemonkey从/store/account页面中汇总值,然后在该页面上显示最终值.
下面列出的代码可以从/store/account页面中总计我想要的值.但是,我想在用于第二个URL的脚本中插入代码,因此我可以将其添加到同一页面上.
// ==UserScript==
// @name Google Play
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @grant GM_setValue
// @grant GM_getValue
// ==/UserScript==
var startParam = location.search.match (/\bstart=(\d+)/i);
if (startParam) {
var totalPrice = 0;
var startNum = parseInt (startParam[1], 10);
if (startNum === 0) {
GM_setValue ("TotalPrice", "0");
}
else {
totalPrice = parseFloat (GM_getValue ("TotalPrice", 0) );
}
$("#tab-body-account .rap-link").each( function () {
var price = $(this).attr ("data-docprice").replace (/[^\d\.]/g, …Run Code Online (Sandbox Code Playgroud) 请参考具有相同的JavaScript以便在网页和iframe中运行的技术,如此答案所述:
例如,假设您在domain_A.com上具有此页面:
<html>
<body>
<iframe src="http://domain_B.com/SomePage.htm"></iframe>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
如果您像这样设置@match指令:
// @match http://domain_A.com/*
// @match http://domain_B.com/*
Run Code Online (Sandbox Code Playgroud)
然后您的脚本将运行两次-一次在主页上,一次在iframe上,就好像它是一个独立页面一样。
使脚本的两个实例相互通信的选项有哪些?
这将是同步实例所必需的。例如,只有在网页脚本实例完成后才让iframe脚本实例执行其任务,反之亦然。
我正在编写一个用户脚本,需要找到与另一个单词相关的单词.我找到了一个网站,我可以访问http://semantic-link.com/#/stack,并且会有一个与stack以下格式相关的单词列表:
<!-- various stuffs here, e.g. <head>, a <div>, another <div>, start of <body> -->
<div id="word0" class="word" onclick="updateTitle("stacks");" style="opacity: 1;">
stacks
</div>
<div id="word1" class="word" onclick="updateTitle("flue");" style="opacity: 1;">
flue
</div>
<div id="word2" class="word" onclick="updateTitle("popped");" style="opacity: 1;">
popped
</div>
<div id="word3" class="word" onclick="updateTitle("overflow");" style="opacity: 1;">
overflow
</div>
Run Code Online (Sandbox Code Playgroud)
在这种情况下,我想stacks从该页面获取字符串.我发现的所有解决方案都不起作用,因为它们:
$.ajax(),, $.get()或$('something').load()仅限于执行它们的域.有没有什么办法可以#word0只使用JavaScript 将元素的内容作为字符串获取?或者,是否有另一种方法可以找到与另一个单词相关的单词?
javascript ×4
jquery ×3
greasemonkey ×2
html ×2
ajax ×1
cross-domain ×1
iframe ×1
mashup ×1
userscripts ×1