userscripts

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

假如想象 提交于 2019-12-17 13:23:32
问题 // 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

How to use GM_xmlhttpRequest in Injected Code?

血红的双手。 提交于 2019-12-17 07:41:31
问题 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

Simulating a mousedown, click, mouseup sequence in Tampermonkey?

拜拜、爱过 提交于 2019-12-17 06:29:29
问题 I would like to simulate a whole click not just document.getElementsByClassName()[0].click(); How do I do that? Search results all seem to be about handling such events, not triggering them. 回答1: Send mouse events. Like so: //--- Get the first link that has "stackoverflow" in its URL. var targetNode = document.querySelector ("a[href*='stackoverflow']"); if (targetNode) { //--- Simulate a natural mouse-click sequence. triggerMouseEvent (targetNode, "mouseover"); triggerMouseEvent (targetNode,

How to change a class CSS with a Greasemonkey/Tampermonkey script?

混江龙づ霸主 提交于 2019-12-17 04:57:10
问题 I'm trying to set the background image of the body, but only where it uses the class banner_url . The HTML is as follows: <body id="app_body" class="banner_url desktopapp" data-backdrop-limit="1"> Basically, I would like to force the page to use the following CSS instead: .banner_url { background: url('http://www.pxleyes.com/images/contests/kiwis/fullsize/sourceimage.jpg') no-repeat center center fixed; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover;

UserScripts & Greasemonkey: calling a website's JavaScript functions

南楼画角 提交于 2019-12-17 04:14:48
问题 I'm creating a UserScript extension for Firefox & Chrome and I'm trying to use some of the code in the website's JavaScript, e.g.: function: myFunction(){ return Grooveshark.playNextSong(); } The problem is when I test this code, Grooveshark is a null reference. I know there are other people who have done it: see BetterGrooveshark But I don't know why my simple extension can't call Grooveshark's JavaScript functions. Do I need to 'append' my script to the document in order for this to work?:

Can a website know if I am running a userscript?

青春壹個敷衍的年華 提交于 2019-12-17 03:34:07
问题 Can, for example, Facebook.com run a version control script on my browser and find out if I am running altered HTML code with the use of a script? Could that be done with a script that can read the HTML code in the cache and produce some kind of hash tag that is sent back to the server and compared with the code that was sent to the client? 回答1: Yes, in theory, a site can deduce the presence of scripts in various situations. This is not foolproof and usually is way too much trouble for the

Injecting JS functions into the page from a Greasemonkey script on Chrome

99封情书 提交于 2019-12-17 03:01:25
问题 I have a Greasemonkey script that works just fine in Firefox and Opera. I struggle with getting it to work in Chrome, however. The problem is injecting a function into the page that can be invoked by code from the page. Here's what I'm doing so far: First, I get a helper reference to the unsafeWindow for Firefox. This allows me to have the same code for FF and Opera (and Chrome, I thought). var uw = (this.unsafeWindow) ? this.unsafeWindow : window; Next, I inject a function into the page. It

Injecting JS functions into the page from a Greasemonkey script on Chrome

♀尐吖头ヾ 提交于 2019-12-17 03:00:04
问题 I have a Greasemonkey script that works just fine in Firefox and Opera. I struggle with getting it to work in Chrome, however. The problem is injecting a function into the page that can be invoked by code from the page. Here's what I'm doing so far: First, I get a helper reference to the unsafeWindow for Firefox. This allows me to have the same code for FF and Opera (and Chrome, I thought). var uw = (this.unsafeWindow) ? this.unsafeWindow : window; Next, I inject a function into the page. It

Transferring information between userscripts in Chrome

丶灬走出姿态 提交于 2019-12-14 04:19:33
问题 I need to have a function execute on a page in one tab when certain conditions are met in another tab. All I need to do is send some kind of nudge to the other tab. I've tried many things already in conjunction with a timer to keep polling: GM_setValue (not supported in Chrome apparently) Setting top.item (apparently doesn't work between tabs) Cookies (even though my userscripts are running in two tabs on the same domain, this doesn't seem to work) Any other ideas? And yes, I do need to use

how to auto trigger my greasemonkey script every time i open a page

不问归期 提交于 2019-12-13 23:13:36
问题 this is my greasemonkey script. I want to auto-trigger it every time I open a reddit page. I want function up_vote_all() { vote_all('arrow up'); } to trigger on every page automatically without me click on the menu item. thanks // ==UserScript== // @name Reddit Mass Vote // @namespace http://reddit.com // @description You can up vote or down vote all comments on any page instantly without having to click each arrow. This is mainly to be used against spammers and trolls. // @include http://www