userscripts

Hijacking a variable with a userscript for Chrome

只愿长相守 提交于 2019-12-29 03:34:13
问题 I'm trying to change the variable in a page using a userscript. I know that in the source code there is a variable var smilies = false; In theory I should be able to change it like that: unsafeWindow.smilies = true; But it doesn't work. When I'm trying to alert or log the variable to the console without hijacking I get that it's undefined. alert(unsafeWindow.smilies); // undefined !!! EDIT: I'm using Chrome if it changes anything... http://code.google.com/chrome/extensions/content_scripts

Apply a Greasemonkey/Tampermonkey/userscript to an iframe?

Deadly 提交于 2019-12-28 02:08:47
问题 The title is pretty much the question: Is it possible to add a Greasemonkey script to an iframed website? If so, how? Thank you. 回答1: In Greasemonkey (And Tampermonkey and most userscript engines) a script will fire on an iframe automatically if it meets the @include, @exclude, and/or @match directives. And, a popular question is how to stop Greasemonkey from firing on iframes. So, if your script had a match like: @match https://fiddle.jshell.net/* It would fire on jsFiddle "output" pages

Why is window (and unsafeWindow) not the same from a userscript as from a <script> tag?

主宰稳场 提交于 2019-12-27 11:04:38
问题 I was facing an issue while developing this small userscript. When I wanted to block every XMLHttpRequest from the running website with my script, nothing was happening (at least with Chrome): function main() { // Override XHR.open with a custom function window.XMLHttpRequest.prototype.open = function() { // Nothing... so it's supposed to block every xhr.open() call } } main(); Same thing when replacing window by unsafeWindow . However, when I used this little trick, everything worked like a

trying to map someFunction.jQuery to “$”

泪湿孤枕 提交于 2019-12-25 05:43:25
问题 I found a function (via this person's github) that I might use in my script that mimics the functionality of an API object. Here's the relevant code from the link: unsafeWindow = (function() { var e1 = document.createElement('p') e1.setAttribute('onclick', 'return window;'); return e1.onclick(); })(); Where the poster says you can use the function in the format unsafeWindow.jQuery Now, I want to be able to use $ instead of the jQuery keyword elsewhere in my code. I tried learning from this

trying to map someFunction.jQuery to “$”

只愿长相守 提交于 2019-12-25 05:42:29
问题 I found a function (via this person's github) that I might use in my script that mimics the functionality of an API object. Here's the relevant code from the link: unsafeWindow = (function() { var e1 = document.createElement('p') e1.setAttribute('onclick', 'return window;'); return e1.onclick(); })(); Where the poster says you can use the function in the format unsafeWindow.jQuery Now, I want to be able to use $ instead of the jQuery keyword elsewhere in my code. I tried learning from this

Onreadystatechange not not working after header redirection in Chrome

≯℡__Kan透↙ 提交于 2019-12-25 04:17:40
问题 I have made a userscript for a forum that resizes images. It works great, except for after posting or editing where it redirects, where onreadystatechange does not fire in Google Chrome. When viewing a thread, EG SomeSite/forums.php?action=viewtopic&topicid=205362 , the userscript works. After editing/posting, EG SomeSite/forums.php?action=viewtopic&topicid=205362&page=p4976670#4976670 , the userscript doesn't work. The problem lies with this code: document.onreadystatechange = function () {

Mimic onclick events in Google Keep with JavaScript

可紊 提交于 2019-12-25 03:11:56
问题 Long story short, Google does not provide an API for Google Keep. So I am trying to "hack" together something that fits my needs. What I've come up with is a JavaScript userscript for Chrome that run on https://keep.google.com . The userscript would, for my needs, iterate through each note and click on the reminder button, then fill out the various parts to add a reminder. I'm stuck on getting the click event to fire for the DIV. The HTML for a single note is below. The line that starts <div

Selecting Checkboxes Based on Value and Parent ID

萝らか妹 提交于 2019-12-24 14:14:53
问题 I'm using Tampermonkey to check checkboxes. The way it's laid out is there's multiple 'Items', each with the same set of checkboxes. I'm trying to have the checkbox pre-selected based on a combination of the checkbox value and the ID (or even title, if that's more ideal). Currently if I use the below, it will select the checkbox but it will do so for Item 1, Item 2, Item 3 and so on when I need to select different options for each. I'm trying to figure out how I go about narrowing the

Get value of span text in Tampermonkey

此生再无相见时 提交于 2019-12-24 07:45:02
问题 I am playing with Tampermonkey scripts in JS. I have a website that shows the user's location and timezone in UTC format. <span class="optional-wrapper"> <span class="UTCText"> ==$0 <!-- react-text: 60 --> " (UTC " <!-- /react-text --> <!-- react-text: 61 --> "+10:00" <!-- /react-text --> <!-- react-text: 62 --> ") " <!-- /react-text --> </span> </span> I want to read the UTC timezone (UTC +10:00) and convert it into a time. I tried something like this but it doesn't work. Can someone point

Detect when new tweets are loaded using jQuery?

試著忘記壹切 提交于 2019-12-23 03:48:04
问题 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!");