gm-xmlhttprequest

“getElementById not a function” when trying to parse an AJAX response?

最后都变了- 提交于 2020-01-08 22:40:25
问题 I'm running GM_xmlhttpRequest (in a Greasemonkey script) and storing the responseText into a newly created HTML element: var responseHTML = document.createElement('HTML'); ... onload: function() { responseHTML.innerHTML = response.responseText; } And then I am trying to find an element in responseHTML : console.log(responseHTML.getElementsByTagName('div')); console.log(responseHTML.getElementById('result_0')); The first works fine, but not the second. Any ideas? 回答1: getElementById is not a

GM_xmlhttpRequest loses data in jQuery .each() statement

萝らか妹 提交于 2019-12-25 07:48:04
问题 I've some pages with URL like this: www.example.com/index.php?id={a number} and each page has the same <select> element: <select id="foo"> <option value="1">Page1 <option value="2">Page2 <option value="3">Page3 <option value="4">Page4 </select> and each page has a <ul> element with different li values: <ul id="other"> <li class="var1">some_value1_page[n]</li> <li class="var2">some_value2_page[n]</li> </ul> The Greasemonkey script takes the <select> element (in any page) and gets the 'id' page

Looping GM_xmlhttpRequest gives “TypeError Null” on a variable

眉间皱痕 提交于 2019-12-20 04:24:32
问题 I have some links in a page. I want to count the responses of each link and insert the numbers in front of the links. Here is what I have: var links = document.evaluate('..../td[1]/font//a[@href]', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); var headings = document.evaluate('.../td[1]',document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null) for(var i = 0; i < links.snapshotLength; i++){ var urls = links.snapshotItem(i).href; GM_xmlhttpRequest({ method: 'GET', url:

get 2 different url using xmlhttp.open

空扰寡人 提交于 2019-12-11 17:56:08
问题 Need help on this following code. the problem is it only trigger the last xmlhttp.open not both. code as below. <script type="text/javascript"> function loadXMLDoc(obj){ var xmlhttp; var flag; var mycode; mycode = obj; if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); }else{// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function(){ if (xmlhttp.readyState==4 && xmlhttp.status==200){ } }

How to obtain a cookie from a remote domain using Greasemonkey?

岁酱吖の 提交于 2019-12-11 12:26:21
问题 I'm writing a Greasemonkey (v2.3) script that basically screen-scrapes the contents served by lema.rae.es/drae/srv/search, for lack of an API of any sort. The thing is, I want to query that URL from Google Translate, a different domain. For that, I can use GM_xmlhttpRequest without problems, but a GET request to a specific URL (for instance lema.rae.es/drae/srv/search?val=test) yields an HTML page with a hidden form that gets POSTed after calling the challenge() javascript function -- which

ReferenceError: GM_xmlhttpRequest is not defined

北战南征 提交于 2019-12-09 15:21:26
问题 I get a ReferenceError in the following userscript code: // ==UserScript== // @name ... // @namespace ... // @description ... // @include ... // @grant GM_xmlhttpRequest // ==/UserScript== console.log(GM_info); try { console.log(GM_xmlhttpRequest({ method: "GET", url: "http://google.ca/", synchronous: true }).readyState); } catch (e) { console.log(e); } ... It first logs GM_info successfully, then logs the ReferenceError. (I'm using Firefox/Firebug.) ReferenceError: GM_xmlhttpRequest is not

Tampermonkey's GM_xmlhttpRequest not implementing 'context' property?

被刻印的时光 ゝ 提交于 2019-12-06 11:04:48
问题 I have written a UserScript for Greasemonkey (Firefox) and am testing it for compatibility with Chrome's Tampermonkey, and getting errors in the developer console: Uncaught TypeError: Cannot read property 'profile_url' of undefined Uncaught TypeError: Cannot read property 'encoded_name' of undefined The errors seem to be referencing the onreadystatechanged callback of GM_xmlhttpRequest which is called like this: var flairs = document.querySelectorAll('span.flair'); var steam_re = /(?:(?:https

Tampermonkey's GM_xmlhttpRequest not implementing 'context' property?

て烟熏妆下的殇ゞ 提交于 2019-12-04 15:20:28
I have written a UserScript for Greasemonkey (Firefox) and am testing it for compatibility with Chrome's Tampermonkey, and getting errors in the developer console: Uncaught TypeError: Cannot read property 'profile_url' of undefined Uncaught TypeError: Cannot read property 'encoded_name' of undefined The errors seem to be referencing the onreadystatechanged callback of GM_xmlhttpRequest which is called like this: var flairs = document.querySelectorAll('span.flair'); var steam_re = /(?:(?:https?:\/\/)?www\.)?(?:steam|pc)(?:community\.com\/?(?:(id|profiles)\/?)?|[\s\-_]*id)?[\/:\s\|]*(.{2,}?)(?:[

ReferenceError: GM_xmlhttpRequest is not defined

随声附和 提交于 2019-12-04 02:57:13
I get a ReferenceError in the following userscript code: // ==UserScript== // @name ... // @namespace ... // @description ... // @include ... // @grant GM_xmlhttpRequest // ==/UserScript== console.log(GM_info); try { console.log(GM_xmlhttpRequest({ method: "GET", url: "http://google.ca/", synchronous: true }).readyState); } catch (e) { console.log(e); } ... It first logs GM_info successfully, then logs the ReferenceError. (I'm using Firefox/Firebug.) ReferenceError: GM_xmlhttpRequest is not defined Why do I get this error? I had the same problem, and what fixed it for me was adding this at the

Promise not returning value of request

被刻印的时光 ゝ 提交于 2019-12-02 12:40:17
问题 I have this promise: function getAPI(token) { return new Promise((resolve, reject) => { console.log("Request API"); GM_xmlhttpRequest({ method: "GET", url: "URL"+token, onload: function(response) { console.log(response.responseText); if( response.responseText == "NOT_ANSWER" || response.responseText.indexOf("ERRO") > -1 ){ console.log(response.responseText + " - Calling Myself in 5 Seconds"); setTimeout(function(){ getAPI(token); },5000); } else{ console.log('Call API - Giving Result');