userscripts

Check if a website is making X http request with javascript

房东的猫 提交于 2019-12-08 02:31:17
问题 I've been searching for a while but all I could find was examples on how to actually make those requests... What I'm trying to do is to check if a website is making an http request after I click a button to X site Ex. http://test.s3.amazonaws.com/test/1.txt I'm guessing there a way to get all the outgoing requests and then filter the list but I can't even get the requests What I've done so far is just inserting the eventlistener to check that X button has been clicked and then is when I'd

Submit autofill (password input field)

只谈情不闲聊 提交于 2019-12-07 23:54:42
问题 I want to submit an autofilled password form using a userscript/tampermonkey in chrome. However it doesn't work - the fields the password field remains empty (server response or even with alert messages) until the window is actually controlled by a user (any actual keyboard press or mouse click). This seems important if you want a userscript to automate logins without hard-coding the passwords into your userscript. Does anyone have an explanation for that and/or a workaround? I tried all ways

Access an existing copy of jQuery on the target page

こ雲淡風輕ζ 提交于 2019-12-07 23:29:14
问题 I am writing a small userscript to get some content from a server and add it to a tie. The site has jQuery, how can I just use the site's jQuery instead of @require (because Chrome doesn't support this now)? 回答1: Use an existing copy of jQuery with code like this: function main () { /*--- Put all of your code here. Use jquery with $ or however the target page uses it. */ } function addJS_Node (text, s_URL, funcToRun) { var D = document; var scriptNode = D.createElement ('script'); scriptNode

appendedHow do I extract the text from a (dynamic) div, by class name, using a userscript?

牧云@^-^@ 提交于 2019-12-07 21:03:14
问题 How do I extract the value 2083236893 from the following object using JavaScript? <div class="gwt-Label">2083236893</div> I installed Greasemonkey 3.17 for Firefox 52.2.1 (32-bit) and tested every code example provided and failed. var html = document.getElementsByClassName("gwt-Label")[0]; alert(html.innerHTML); The above example comes from: Accessing Div, by class name, with javascript . Should the code be run on full download of the web page? Appended: var elements = document

Is the Immediately-Invoked Function Expression (IIFE) pattern really necessary when writing userscripts?

只愿长相守 提交于 2019-12-07 12:43:33
问题 My question is quite similar to What is the purpose of a self executing function in javascript?, however it concerns userscripts (specifically for GreaseMonkey) instead. I see that some userscripts are distributed with this pattern, and some are not. Example of script with the IIFE pattern: (source) // ==UserScript== // (...) // ==/UserScript== (function(){ // if <condition> document.location.href += '?sk=h_chr'; // ... })(); Example of script without it: (source) // ==UserScript== // (...) /

Chrome iframe parent is undefined

醉酒当歌 提交于 2019-12-07 12:12:57
问题 I have this script for Gmail. It runs inside the canvas_frame iframe. I want to get a handle to the parent document, using parent.document . But in Chrome tells me that it's undefined. Works fine in Firefox, but blows up on Chrome. So how exactly do I get a handle to the parent document, from within an iframe, in Chrome. Chrome ver: 11.0.686.3 Here's the code that's failing: function init() { try { if(parent == null) { console.log(typeof parent); window.setTimeout(init, 200); return; } //

How to completely disable all exit warning/confirm messages with userscript?

♀尐吖头ヾ 提交于 2019-12-07 06:19:44
问题 I am using chrome in an isolated environment to scan malicious websites to analyze their data to create blacklists. This process is completely automated by userscripts and browser extensions. The problem is that some sites are able to show an exit dialog on beforeunload or unload (I will refer to these as events ). I already override these events , but when the site override my override again, the whole process stops. I mean they can redefine the events with AJAX calls, obfuscated scripts,

Detect when new tweets are loaded using jQuery?

烈酒焚心 提交于 2019-12-06 21:54:30
You know how when you scroll to the bottom of a profile page (I'm talking about a user's personal page, not the timeline), new tweets are loaded automatically. I'm writing a UserScript in which I want to execute a function every time those new tweets are loaded. But I can't figure out a way to detect this new tweets loaded event. I assume its an AJAX request, right? So I tried the below two functions but to no avail. $(document).ajaxComplete(function() { alert("Complete! New tweets loaded!"); }); $(document).ajaxSuccess(function() { alert("Success! New tweets loaded!"); }); Here's what I have

How can I click a <li> item with Greasemonkey?

久未见 提交于 2019-12-06 16:00:18
问题 <ul class="myList clearfix" id="thismyList"> <li class="myBullet" id="answer1">blabla1</li> <li class="myBullet" id="answer2">blabla2</li> <li class="myBullet" id="answer3">blabla3</li> </ul> In this page, how can I automatically click item blabla2 ? 回答1: The shortest and most powerful is probably the XPath way (btw - it's one of the few w3 specifications that are actually a very good and helpful read). You can have almost any conditions you want to have. var xresult = document.evaluate("//*

Access an existing copy of jQuery on the target page

时光毁灭记忆、已成空白 提交于 2019-12-06 12:59:52
I am writing a small userscript to get some content from a server and add it to a tie. The site has jQuery, how can I just use the site's jQuery instead of @require (because Chrome doesn't support this now)? Use an existing copy of jQuery with code like this: function main () { /*--- Put all of your code here. Use jquery with $ or however the target page uses it. */ } function addJS_Node (text, s_URL, funcToRun) { var D = document; var scriptNode = D.createElement ('script'); scriptNode.type = "text/javascript"; if (text) scriptNode.textContent = text; if (s_URL) scriptNode.src = s_URL; if