greasemonkey

Greasemonkey to redirect site URLs from .html to -print.html?

孤街醉人 提交于 2019-12-02 05:05:33
Need help making a script for Greasemonkey that will help me read forums more efficiently. Redirect all pages ending in .html : http://www.site.com/thread-category/4525-url.html To this printable version URL: http://www.site.com/thread-category/4525-url-print.html (Add -print , just before ending .html . To do this accounting for possible URL parameters and hash tags: // ==UserScript== // @name _Redirect site.com to print.html URL's // @include /site\.com\/thread.+?\.html\b/ // @grant none // @run-at document-start // ==/UserScript== if ( ! /print\.html$/i.test (location.pathname) ) { var

How can I prevent CSS from affecting certain element?

落爺英雄遲暮 提交于 2019-12-02 05:01:33
问题 I am writing a GreaseMonkey script that sometimes creates a modal dialog – something like <div id="dialog"> Foo </div> . But what can I do if the site has something like #dialog { display: none !important; } ? Or maybe the owner of some site is paranoid and has something like div { display: none !important; } div.trusted { display: block !important; } because he doesn't want people like me adding untrusted content to his page. How can I prevent those styles from hiding my dialog? My script

Get access to the console once the console object reference was changed

不问归期 提交于 2019-12-02 05:00:52
问题 I like making userscripts. It's real fun to get some more control of your favorite page or just speed up it's loading. Curently, I came across a problem that a page either defines console reference to a new dummy object: window.console = {log: function() {}, info: function() {} ... }; Or it even destroys the functions: window.console.log = function() {}; window.console.info = function() {}; ... I'm using window to make it obvious that I'm talking about the global scope. Also, I didn't use

Javascript variable scope in a JS URI, or how to write page-scope objects?

大城市里の小女人 提交于 2019-12-02 04:39:29
I'm writing a Greasemonkey script that I'm trying to use in Chrome and Firefox. I know you can't use unsafewindow in Chrome like you can in Firefox, so I've been attempting to use jS-uris like in the answer for: Greasemonkey, Chrome and unsafeWindow.foo() . when I try the following: location.assign("javascript:var tutu = 'oscar';"); location.assign("alert('1:' + tutu);"); alert('2:' + tutu); I receive an error showing that "tutu" is undefined. Obviously what I'm not understanding is the scope of these variables. I need to make global functions and variables for what I'm working on. What am I

Looping GM_xmlhttpRequest gives “TypeError Null” on a variable

和自甴很熟 提交于 2019-12-02 04:16:45
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: urls, onload function (res){ var dt = document.implementation.createDocumentType("html", "-//W3C//DTD HTML

How to reload only a userscript, i.e. without reloading the page?

两盒软妹~` 提交于 2019-12-02 03:54:48
I'm working on a Greasemonkey userscript for a web app that needs configuration steps before I can actually test my userscript's functionality. So every time I reload the page – to refresh my userscript from the updated file –, I have to reconfigure the web app before testing. Needless to say, this gets old very quickly. Is there a way to reload only the userscript , preferably from the userscript itself? I would want to e.g. bind the reload to a keyboard shortcut. I thought that this must be a very common need, but I came up empty-handed when trying to find a solution. Ben Connor Hansell

How do I auto-submit a form with Greasemonkey?

不打扰是莪最后的温柔 提交于 2019-12-02 03:34:57
问题 I'm trying to autosubmit a form with greasemonkey however I'm not sure how to do it with this button. The button seems to have the following properties a class="blue-button" href="javascript:void(0)" onclick="Form.submit(this);" and the only form I see above is <form xmlns="http://www.w3.org/1999/xhtml" xmlns:s="http://www.blizzard.com/ns/store" action="/account/management/add-game.xml" autocomplete="off" method="post"> The page is here you can use "email9999@trash2009.com" and "a1a1a1a1" as

How to convert a jQuery filter for use with waitForKeyElements?

拥有回忆 提交于 2019-12-02 03:25:28
问题 This code removes tweets with less than 3 retweets, but now I have the refresh (AJAX) issue. How can I add the waitForKeyElements function to fix it? $('.js-stream-item:has(span.ProfileTweet-action--retweet)').filter(function() { return parseInt($(this).find('span.ProfileTweet-actionCount').attr('data-tweet-stat-count')) < 3; }).remove(); 回答1: To convert a static jQuery filter, like that, to an AJAX-aware waitForKeyElements() use is not too hard: Your base selector just becomes the selector

Get access to the console once the console object reference was changed

浪尽此生 提交于 2019-12-02 02:39:14
I like making userscripts. It's real fun to get some more control of your favorite page or just speed up it's loading. Curently, I came across a problem that a page either defines console reference to a new dummy object: window.console = {log: function() {}, info: function() {} ... }; Or it even destroys the functions: window.console.log = function() {}; window.console.info = function() {}; ... I'm using window to make it obvious that I'm talking about the global scope. Also, I didn't use quick assigment to the same function on purpose, in the second example Now how would you deal with this?

How to convert a jQuery filter for use with waitForKeyElements?

吃可爱长大的小学妹 提交于 2019-12-02 02:21:11
This code removes tweets with less than 3 retweets, but now I have the refresh (AJAX) issue. How can I add the waitForKeyElements function to fix it? $('.js-stream-item:has(span.ProfileTweet-action--retweet)').filter(function() { return parseInt($(this).find('span.ProfileTweet-actionCount').attr('data-tweet-stat-count')) < 3; }).remove(); Brock Adams To convert a static jQuery filter, like that, to an AJAX-aware waitForKeyElements() use is not too hard: Your base selector just becomes the selector parameter. EG: waitForKeyElements (".js-stream-item:has(span.ProfileTweet-action--retweet)"...