greasemonkey

Chrome userscript error: “Unsafe JavaScript attempt to access frame”

六月ゝ 毕业季﹏ 提交于 2019-11-27 15:20:08
// the iframe of the div I need to access var iframe = document.getElementsByTagName("iframe")[2]; var innerDoc = iframe.contentDocument || iframe.contentWindow.document; // resize 'player' in the iframe innerDoc.getElementById('player').width = "1000px"; innerDoc.getElementById('player').height = "650px"; Running in a userscript for this url: http://www.free-tv-video-online.me/player/sockshare.php?id=24DA6EAA2561FD60 Why does Chrome come out with this error and fail the script?: Unsafe JavaScript attempt to access frame with URL http://www.sockshare.com/embed/24DA6EAA2561FD60 from frame with

How to use GM_xmlhttpRequest in Injected Code?

旧时模样 提交于 2019-11-27 15:11:52
I am writing a userscript that is injected into a webpage. The script reads some data from a web-server and I want to send messages to a listening application to react to the data. For now, all I'm doing is trying to send a string command to my listening application and see if I can read it. My code worked before it was injected, but afterwards I get an "undefined reference error". I suspect that this has something to do with this "Greasemonkey access violation" . However, I have been unable to find a solution that works. I'm developing in Chrome. Here is the section of code I can't get to

Greasemonkey, overriding website functions

馋奶兔 提交于 2019-11-27 14:09:04
问题 i've been reading a lot and have been trying to get this done for about 5 hours now... so here it is I want to write a script that will override a function dummy() {$.ajax(...)}; on a website. here is how i'm trying to do it unsafeWindow.dummy = function(data){differantFunction(); $.ajax(...);}; function differantFunction(){ ... } but the dummy function that would have been called up to do something on the original page... now just does nothing. //update I tried running that function i'm

Opening and closing a new tab when downloading

百般思念 提交于 2019-11-27 13:13:33
问题 On many websites ( Dropbox being a good example), when you click on a document to download it, it opens a new window/tab, then the download prompt appears, and the tab/window immediately closes itself (while the prompt remains open). How do I replicate this behavior using javascript? I think one approach would be to detect the appearance of that download prompt, then use window.close() . However, I'm not sure how to detect that particular prompt. A cross-browser solution is preferred, but

Unique element ID, even if element doesn't have one

一世执手 提交于 2019-11-27 12:47:15
问题 I'm writing a GreaseMonkey script where I'm iterating through a bunch of elements. For each element, I need a string ID that I can use to reference that element later. The element itself doesn't have an id attribute, and I can't modify the original document to give it one (although I can make DOM changes in my script). I can't store the references in my script because when I need them, the GreaseMonkey script itself will have gone out of scope. Is there some way to get at an "internal" ID

How to automatically click a confirm box?

时间秒杀一切 提交于 2019-11-27 12:03:46
问题 My script clicks an image on a site. The image has an anchor href and an onclick href , but the onclick href has a confirm box that pops up once it's clicked. The onclick HTML is: onClick="this.href='link2';if (!confirm('Are you sure?')) { return false; } How do I get the script to click OK in that confirm box, once it pops up? I'm using this function to click the picture link: function click(elm) { var evt = document.createEvent('MouseEvents'); evt.initMouseEvent('click', true, true, window,

can i remove the X-Requested-With header from ajax requests?

对着背影说爱祢 提交于 2019-11-27 11:37:06
问题 I wanted to know if anyone has had experience with trying to remove the 'X-Requested-With' header from the ajax request made by jquery (or plain JS). is it possible? 2nd part: do you know if Grease Monkey's ajax requests set this header? Thanks header looks like this: X-Requested-With XMLHttpRequest 回答1: "2nd part: do you know if Grease Monkey's ajax requests set this header?" No, Greasemonkey's GM_xmlhttpRequest() does not set this header (although you can certainly add it). The default

How/Where to store data in a Chrome Tampermonkey script?

我的未来我决定 提交于 2019-11-27 11:34:38
问题 I wrote one Greasemonkey/Tampermonkey script for Facebook . I needed to store data to retrieve it later. For that I used localStorage . That was working fine. But I noticed that after few hours all data which I stored was removed automagicllay. Probably Facebook itself deletes all localStorage data. Now, I searched for alternatives. Cookies : No this will be removed when user clears history. Web SQL : Apparently it is dropped by w3.org. So in near future I assume chrome might not be using web

how to run greasemonkey script before the page content is displayed?

我怕爱的太早我们不能终老 提交于 2019-11-27 11:14:06
问题 I am writing a plug-in for Firefox and using greasemonkey script to do that (I compile the user script using this tool http://arantius.com/misc/greasemonkey/script-compiler). The issue is that the script is run after the page is fully loaded. Meaning the user would see the viewed page in its original form and then the script will apply the changes that I made. My question is there a way to run the user script before the contents of the page is displayed to the user, so the user would only the

How to use XMLHttpRequest to download an HTML page in the background and extract a text element from it?

百般思念 提交于 2019-11-27 09:38:17
I want to make a Greasemonkey script that, while you are in URL_1, the script parses the whole HTML web page of URL_2 in the background in order to extract a text element from it. To be specific, I want to download the whole page's HTML code (a Rotten Tomatoes page) in the background and store it in a variable and then use getElementsByClassName[0] in order to extract the text I want from the element with class name "critic_consensus". I've found this in MDN: HTML in XMLHttpRequest so, I ended up in this unfortunately non-working code: var xhr = new XMLHttpRequest(); xhr.onload = function() {