需要一个功能:
function isGoogleURL(url) { ... }
Run Code Online (Sandbox Code Playgroud)
如果URL属于Google,则返回true.没有误报; 没有误报.
幸运的是,这是一个参考:
.google.com .google.ad .google.ae .google.com.af .google.com.ag .google.com.ai .google.am .google.it.ao .google.com.ar .google.as .google.at .google.com.au .google.az .google.ba .google.com.bd .google.be .google.bg .google.com.bh .google.bi .google.com.bn .google .com.bo .google.com.br .google.bs .google.co.bw .google.com.by .google.com.bz .google.ca .google.cd .google.cg .google.ch .google .ci .google.co.ck .google.cl .google.cn .google.com.co .google.co.cr .google.com.cu .google.cz .google.de .google.dj .google.dk .google.dm .google.com.do .google.dz .google.com.ec .google.ee .google.com.eg .google.es .google.com.et .google.fi .google.com.fj .google.fm .google.fr .google.ge .google.gg .google.com.gh .google.com.gi .google.gl .google.gm .google.gp .google.gr .google.com.gt .google.gy .google.com.hk .google.hn .google.hr .google.ht …
我的一位朋友在过去一年左右上传了大约20个左右的大自然画廊到webshots.com,然而,我刚刚为她购买了付费的Flickr帐户作为生日礼物,我想下载所有她的来自网页截图的照片,一旦她收到有关她的帐户升级的电子邮件(她不在国外 - 没有互联网访问权限),就让她准备好上传到Flickr.
我无法访问她的webshots帐户,因此我使用Greasemonkey和DownThemAll开始将她的图像保存到桌面上的文件夹中.
我对javascript有点新,而Greasemonkey可用的所有"用户脚本"并不完全符合我的需要.
加载图库页面时:
(http://[category].webshots.com/album/[album-id]),
Run Code Online (Sandbox Code Playgroud)
我需要Greasemonkey脚本来查找图像的所有链接:
(http://[category].webshots.com/photo/[photo-page-id])
Run Code Online (Sandbox Code Playgroud)
并重新编写它们以反映这个方案:
(http://community.webshots.com/photo/fullsize/[photo-page-id])
Run Code Online (Sandbox Code Playgroud)
这很容易吗?看起来似乎是这样,但我似乎无法做到正确.
这是我当前的Greasemonkey脚本不起作用:
// ==UserScript==
// @name Webshot Gallery Fixer
// @namespace WGF
// @description Fixes webshot galleries
// @include http://*.webshots.com/*
// ==/UserScript==
var links = document.getElementsByTagName("a"); //array
var regex = /^(http:\/\/)([^\.]+)(\.webshots\.com\/photo\/)(.+)$/i;
for (var i=0,imax=links.length; i<imax; i++) {
links[i].href = liks[i].href.replace(regex,"$1community$3fullsize/$4");
}
Run Code Online (Sandbox Code Playgroud) 我正在编写一个Greasemonkey脚本,如果该页面只有一个搜索结果,则会重定向用户.我正在尝试从一个包含许多父表的表中获取链接.我试图获取链接的页面部分如下所示:
<tr class="odd">
<td class="name first">
<a href="need this one">Text</a>
</td>
Run Code Online (Sandbox Code Playgroud)
尝试了document.getElementById('name first'),但仍然没有成功.没有任何外部库我需要帮助.该页面的设计使得偶数单元格的背景变暗,所以如果没有名为"even"的类,那么它假定只有一个结果,并且该部分正常工作.
我有一个链接,我需要点击使用greasemonkey
<a href="/attack/index/1016587">Attack This Player</a>
,这是代码的事情是href可以根据页面更改,唯一的静态代码是'攻击这个播放器的文本
我现在有
function click_element(element)
{
var event = document.createEvent("MouseEvents");
event.initMouseEvent("click", true, true, document.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
element.dispatchEvent(event);
return;
};
click_element( document.evaluate("//a[I DON'T KNOW WHAT TO PUT HERE]",document,null,9,null).singleNodeValue );
Run Code Online (Sandbox Code Playgroud)
这个目前适用于带有ID,类等的链接(对不起所有的大写,但它只是为了引起对该区域的注意)
感谢任何帮助,我不是那么先进的JavaScript
Reblerebel
我试图接到一个GM_xmlhttpRequest同步行为的电话,但我不能像我期望的那样让它工作:
function myFunction (arg) {
var a;
GM_xmlhttpRequest ( {
method: "GET",
url: "http://example.com/sample/url",
synchronous: true,
onload: function (details) {
a = details.responseText;
}
} );
return a;
}
b = myFunction ();
alert (b);
Run Code Online (Sandbox Code Playgroud)
我从来没有得到任何回报b; 这是未定义的.我在这里缺少一些步骤吗?
我使用的是Greasemonkey的v0.9.13和Firefox的v9.0.1.
我正在为一个有很多flash文件的网站制作Greasemonkey脚本.我想制作一个闪存的哈希,问题是闪存文件高达10兆字节.
这很慢; 我希望能够只获取前80KB的哈希值.最终结果是将包含不需要的内容的某些Flash文件列入黑名单的简单方法.我的脚本如何仅获取文件的前80 KB(左右)?
我无法让我的Greasemonkey脚本工作......
GM_registerMenuCommand("What's My IP Address?", function(){
GM_xmlhttpRequest({
method: "GET",
url: "http://tools.ip2location.com/ib2",
onerror: function(oEvent){ alert("Error " + oEvent.target.status + " occurred while receiving the document."); },
onload: function(response){
if (response.readyState !== 4 || response.status !== 200) return;
// we can parse now
var myregexp = /<a[^>]*>([\s\S]*?(?:Your IP Address)[\s\S]*?)<\/a>/i;
var match = myregexp.exec(response.responseText);
if (match != null) {
// got match
subject = match[1];
// format first line
subject_2 = subject.replace(/<br><b>/mg, " ");
// remove html
subject_3 = subject_2.replace(/<\/?[a-z][a-z0-9]*[^<>]*>|<!--[\s\S]*?-->/ig, "");
// now …Run Code Online (Sandbox Code Playgroud) 假设有一个站点在html脚本标记中包含一个外部.js文件,如下所示:
<script src="somescript.js">
Run Code Online (Sandbox Code Playgroud)
我希望lublessmonkey拦截每个这样的脚本,并在执行之前更改其中的某些值。例如,我想将其中所有出现的值“ 400”更改为“ 300”,然后继续加载页面,就像脚本使用这些值而不是原始值一样。目前,我在油脂单中使用以下代码:
function replaceTargetJavascript (scriptNode) {
var scriptSrc = scriptNode.textContent;
scriptSrc = scriptSrc.replace (
/'400'/,
"'300'"
);
addJS_Node (scriptSrc);
}
document.addEventListener("beforescriptexecute", function(e) {
checkForBadJavascripts ( [
[false, /'400'/, replaceTargetJavascript]
] );
}, true);
Run Code Online (Sandbox Code Playgroud)
根据我的消息来源,哪种方法是正确的方法,但没有用。谁能帮我解决这个问题?
我正在开展一个需要网站数据的项目.该数据的问题在于它被组织成许多不同的网页,其中URL中包含序列号.为了解决这个问题,我在Tampermonkey中编写了一个简单的脚本,它循环遍历这些页面并在脚本中的字符串变量中获取数据.
现在出现了真正的问题,我该如何存储这些数据.我知道我无法写入我的电脑上的文件,但可以将数据显示在浏览器的单独选项卡上,这样我就可以在循环完成后将其复制并粘贴到本地文件中?我希望在每个循环中附加一个字符串存储
我不想使用,GM_setValue因为我希望原始文本格式的数据(如.txt文件)
但是,如果它可以直接写入我的PC上的文件而不使用外部库,那么这将是首选.
我需要在公司内部网站上托管用户脚本。我如何构建该链接href以便Greasemonkey在单击链接时安装用户脚本?
我尝试了一个简单的方法,<a href="user.js">Install Userscript</a>但Chrome和Firefox仅显示文件源,而不安装用户脚本。
greasemonkey ×10
javascript ×8
tampermonkey ×3
html ×2
ajax ×1
database ×1
download ×1
href ×1
jquery ×1
userscripts ×1