userscripts

How to detect if a userscript is installed from the Chrome Store?

巧了我就是萌 提交于 2019-12-04 15:01:48
I want to notify the user when an update for my Greasemonkey/UserScript is available. However when the user has installed the script from the Chrome Web Store, I don't want to bother because it has auto-update functionality. I first thought about using $.browser==chrome but it is also possible that a Chrome user has installed it using Tampermonkey. (Furthermore if the site would update jQuery, $.browser would stop working) So, is it possible to detect that it is a UserScript installed through the Chrome Web Store? Brock Adams Probably best to just let the user know that an update is available,

Scriptish script needs the page refreshed to run?

若如初见. 提交于 2019-12-04 13:44:53
This script assists in a checkout process at an online store. All is working correctly, except the need to refresh the page to get the program to run initially. I wonder if it is a cache problem because it works on other products that have been previously viewed. I also tried tinkering with the @run-at to no avail. I'm using the Scriptish extension and it is a standalone .js file. // ==UserScript== // @id proper-id // @name proper-name // @version 1.0 // @namespace // @description // @include proper-url-here // @include about:blank // @run-at window-load // ==/UserScript== for (var i=0; i

Userscript to click button

青春壹個敷衍的年華 提交于 2019-12-04 10:44:05
I would like to click a buy now button using greasemonkey. // ==UserScript== // @name script // @namespace sc // @include * // @version 1 // @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js // @require https://gist.github.com/raw/2625891/waitForKeyElements.js // @grant GM_addStyle // ==/UserScript== waitForKeyElements ("#buy-now", triggerMostButtons); function triggerMostButtons (jNode) { triggerMouseEvent (jNode[0], "mouseover"); triggerMouseEvent (jNode[0], "mousedown"); triggerMouseEvent (jNode[0], "click"); triggerMouseEvent (jNode[0], "mouseup"); } function

Programmatically fill reactjs form

爱⌒轻易说出口 提交于 2019-12-04 10:18:42
I am writing an userscript and I can't manage to fill a form made by reactjs. My code: document.querySelector("#id-username").value = "name@domain.xx"; // Attempt to notify framework using input event document.querySelector("#id-username").dispatchEvent(new Event("input", {data:"name@domain.xx"})); // Attempt to notify framework using change event document.querySelector("#id-username").dispatchEvent(new Event("change")); // This doesn't help either document.querySelector("#id-username").dispatchEvent(new Event("blur")); // Submit the form using button (it's AJAX form) document.querySelector(

Adding a custom keyboard shortcut using userscript to Chrome with Tampermonkey

こ雲淡風輕ζ 提交于 2019-12-04 08:29:17
I would like to add some custom keyboard shortcuts to a certain web page. Using the accepted answer from this question as a guide: How can I add a JavaScript keyboard shortcut to an existing JavaScript Function? I made my own little function and added a listener: // ==UserScript== // @name ChartGame // @namespace http://www.chartgame.com/ // @version 0.1 // @description enter something useful // @match http://www.chartgame.com/play* // @copyright 2012+, You // ==/UserScript== function doc_keyUp(e) { switch(e.keyCode) { case 49: //1 mon_clk(3); break; case 50: mon_clk(6); break; case 83: //s

Pass a variable to new page

隐身守侯 提交于 2019-12-04 05:35:40
问题 I am trying to pass a variable from one page, load another and enter that information. something Like this: When 127.0.0.1/test.html&ID=1234 location.href = "127.0.0.1/newpage.html" if (location.href == newpage.html){ var e = document.GetElementById("Loginbx"); e.Value = ID } I don't have access to modify 127.0.0.1/test.html nor newpage.html but would like to pass variables to them from another. Is this possible? 回答1: You could pass the values on the query string and then read those: location

How do I prevent the browser from preloading the <video> tag?

放肆的年华 提交于 2019-12-04 02:39:23
I have written a user script extension for Chrome with JavaScript in order to prevent video and audio tags from downloading automatically on pageload This is the code: var videoTags = document.getElementsByTagName("Video"); var i; for(i=0; i<videoTags.length; i++) { videoTags[i].setAttribute("preload", "none"); videoTags[i].removeAttribute("autoplay"); } var audioTags = document.getElementsByTagName("audio"); var i; for(i=0; i<audioTags.length; i++) { audioTags[i].setAttribute("preload", "none"); audioTags[i].removeAttribute("autoplay"); } And this is the manifest.json file: { "content_scripts

How to dynamically inject a JavaScript function?

℡╲_俬逩灬. 提交于 2019-12-03 08:59:54
I am stuck using a product with a horrible UI at work and trying to make it palatable via UserScripts in Chrome. To that end, I am trying to inject a JavaScript function into the page via the UserScripts mechanism: // find the div var dropDown = document.getElementById("tstGlobalNavigation_ddlChooseProject"); // inject function dropDown.innerHTML = dropDown.innerHTML + "<script>function gotoIncident(){alert('111')}</script>"; // inject a button dropDown.innerHTML = dropDown.innerHTML + "   <input type='button' name='btnSearch' value='Go' onClick='javascript:gotoIncident()' >"; As you can see I

Why doesn't jQuery work in Chrome user scripts (Greasemonkey)? [duplicate]

╄→гoц情女王★ 提交于 2019-12-03 07:01:45
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: How can I use jQuery in Greasemonkey scripts in Google Chrome? I'm unable to get this user script to work in Google Chrome. // ==UserScript== // @name voip // @namespace 1 // @description voip // @include * // @require http://jquery.com/src/jquery-latest.js // ==/UserScript== $(document).ready(function() { alert("Hello world!"); }); The alert doesn't show up. If I just put alert("Hello world!"); in the script,

Modify new elements when they are added

可紊 提交于 2019-12-02 21:28:06
问题 This is done by my userscript on page load: $('a.people').each(function (index, value) { $('<i>'+$(value).text()+'</i>').insertBefore(value); }); The web app the userscript targets, adds new $('a.people') elements when the user does various actions. How can I run my code for the newly added elements? Is there an event which is triggered when new elements are added to the DOM? I don't want to use setInterval because the code will loop when not required and affect the performance. 回答1: If you