w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Convert a greasemonkey Script after E4x is not supported
If there is a dependency on e4x, try including the JavaScript implementation: e4x.js As an alternative, here are other questions which cover mapping e4x syntax to XPath or XML to JSON: What is the Flex/AS3/E4X equivalent of this xpath query? Howto convert E4X XML Elements into JSON Notation In addition, you can continue to use e4x by accessing the data via yql: Using e4x with yql

Categories : Javascript

"TypeError: can't convert undefined to object" with GreaseMonkey script
You are using .trigger() incorrectly, you need to pass at least the event type argument. $('#triggerAllButton').click(function(e){ e.preventDefault(); $(".btn.trigger").trigger("click"); //.each is implicit on all jQuery methods });

Categories : Javascript

How can I submit this form properly with javascript/greasemonkey?
With jQuery you could submit this form like this: In this function you can process the data of the form. $(document).on("submit", "form", function(e){ e.preventDefault(); // get the data of the form var url = $(this).attr("action"), _csrf_token = $(this).find("input name=['_csrf_token']).val(); // jquery ajax call for example $.ajax( ); });

Categories : Javascript

replacing text between two strings in javascript using greasemonkey
The easiest way to do this would be with a regular expression. var comment = "[youtube]http://www.youtube.com/embed/XGSy3_Czz8k[/youtube]", match = comment.match(/[youtube]([^[]*)[/youtube]/); if (match) { var iframe = document.createElement("iframe"); iframe.src = match[1]; document.body.appendChild(iframe); }

Categories : Javascript

Removing CSS Borders with javascript in greasemonkey/tampermonkey for facebook
border-right is a style property, not an element attribute, so removeAttribute won't work. Instead try this: document.getElementById("mainContainer").style.borderRight = "none"; (Note that border-right becomes borderRight for JavaScript, and make sure you spell names exactly.) However you might prefer user stylesheets. Browser extensions such as Stylish let you write CSS that is applied automatically, instead of going through script. (You can hide things using display: none, or mute them with opacity: 0.5.)

Categories : Javascript

Can latest Tampermonkey / Greasemonkey still not use jQuery AJAX?
jQuery AJAX works fine with Tampermonkey and Greasemonkey, with only one limitation compared to jQuery use in a web page. For example, this cross-origin script works in both Tampermonkey and Greasemonkey: // ==UserScript== // @name _Demonstrate jQuery AJAX from Tampermonkey // @include http://stackoverflow.com/questions/18546180/* // @require http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js // @grant GM_addStyle // ==/UserScript== /*- The @grant directive is needed to work around a design change introduced in GM 1.0. It restores the sandbox. */ $.ajax ( { type: 'GET', url: 'https://api.stackexchange.com/2.1/users/621338?site=stackoverflow&filter=!)2R0ltXnW6.fyPDiHJm', dataType: 'JSON', success: function (apiJson) {

Categories : Jquery

jQuery .ready not getting called from within Greasemonkey script
The alert doesn't fire for two reasons: The browser is redirected from www.ted.com to www.youtube.com right away -- long before the ready event can fire on ted.com. The script is not set to fire on youtube.com at all. If you want the script to fire on both domains, adjust the @include (or @match) directives and then use checks like: if (location.hostname == "www.ted.com") { var url = window.location.href; var talk_name = url.split("/").pop(); talk_name = talk_name.substring(0, talk_name.lastIndexOf('.html')); var youtube_search_url = 'http://www.youtube.com/user/TEDtalksDirector/search?query=' + talk_name; window.location.href = youtube_search_url; } to alter the script's behavior, per domain. Because @grant none is used, the GM script's jQuery c

Categories : Javascript

Adding javascript to a XML file transformed with XSLT using a Greasemonkey script
Don't use onclick. This goes triple for userscripts, as there are additional scope and/or sandbox conflicts. Also, it's a poor idea to try and add JS into the XSLT file/text, and there is no need for script injection in this case either. Use the script to do whatever JS manipulation you have in mind. For example: // ==UserScript== // @name _XML Renderer with javascript functionality // @description Stylesheet and javascript for xml results // @include http://YOUR_SERVER.COM/YOUR_PATH/*.xml // @resource xslFile Q_17998446_transform.xsl // @grant GM_getResourceText // ==/UserScript== var xsl_str = GM_getResourceText ("xslFile"); var processor = new XSLTProcessor (); var dataXSL = new DOMParser ().parseFromString (xsl_str, "text/xml"); processor.importSty

Categories : Javascript

Convert jquery to javascript code
Well, i don't know why you need that but you need to use HTML DOM / Mouse Events instead of jQuery events: object.onmousemove object.onmouseup object.onmousedown Also you need to use an inmediate function instead the jQuery document ready shortcut $(function(){...}): (function(){ // ... your code goes here })()

Categories : Javascript

javascript function convert into jquery equivalent
Seems like a strange way to download a file. In any case, this probably works the same was as the original: if (!iframe.get(0)) { ... } ... and the id property as another poster mentions.

Categories : Javascript

convert short jquery to standalone javascript
You can use the property innerHtml of an element te set its content. To append some content, you should use += Ex: myElement+= "<p>A new paragraph</p>"

Categories : Javascript

how to convert div data into array using javascript or jquery?
Below Code May be help you : <!DOCTYPE html> <html> <head> <style> div { color:red; } </style> <script src="http://code.jquery.com/jquery-1.9.1.js"></script> </head> <body> <div>First</div> <div>Second</div> <div>Third</div> <div>Fourth</div> <script> var elems = document.getElementsByTagName("div"); // returns a nodeList var arr = jQuery.makeArray(elems); arr.reverse(); // use an Array method on list of dom elements $(arr).appendTo(document.body); </script> </body> </html>

Categories : Javascript

How to convert a date to JSON format using javascript or jquery?
How can I convert a date to JSON format JSON has no format for dates. That string you frequently see is a popular convention, nothing more. (And like many conventions, there are variations on that theme.) Looking at it, it's the underlying Epoch value plus the timezone offset. Both of those pieces of information are available from the Date object. The Epoch value comes from getTime, and the timezone offset from getTimezoneOffset (which is in minutes). Using those, you can create a string in that form.

Categories : Javascript

How do you convert a series of javascript (jQuery) button "on clicks" into a loop?
You don't use a loop at all. Give those buttons a class and maybe a data- attribute: <button class="height-setter" data-lift-height="12">Click me</button> And then attach an event handler to them: var lift_height = 0; $('.height-setter').click(function() { lift_height = $(this).data('lift-height'); }); Or, if possible, use their order: <div class="buttons"> <button>One</button> ... </div> And the JS: var lift_height = 0; $('.buttons button').click(function() { lift_height = $(this).index(); });

Categories : Javascript

Convert html encoded string back into html elements jQuery/JavaScript
Here's a quick example. You just pass it into the other jQuery object's html function. JSFiddle HTML: <div id="someInfo">Hello, this is a simple example.<p>Boom, a paragraph.</p></div> <div id="storeHereLater"></div> CSS: $(function(){ var someInfoHTML = $('#someInfo').html(); $('#storeHereLater').html(someInfoHTML); });

Categories : Javascript

How to convert a jquery array to a string array in javascript
Why not using .map() method? var x = $(".container h3").map(function(){ return $(this).text(); }).get(); // ["A", "B", "C", "D", "E"]

Categories : Javascript

How would I remove a DIV if there are no IDs using Greasemonkey?
We might need to see the whole page to work out robust selectors for those <div>s. But, if they always contain iframes with src attributes to undesirable content, then you can use those iframes to hunt down the dastardly divs. Make a list of key text snippets in the bad iframe src attributes. I'm also using jQuery and waitForKeyElements(), in case this content is added by AJAX. So, the script looks something like this: // ==UserScript== // @name _Remove bad divs containing bad iframes // @include http://YOUR_SERVER.COM/YOUR_PATH/* // @require http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js // @require https://gist.github.com/raw/2625891/waitForKeyElements.js // @grant GM_addStyle // ==/UserScript== /*- The @grant directive is needed to work around a de

Categories : Javascript

How to change var value in greasemonkey
If I understand you correctly, this should be an easy fix. You can simply overwrite the variable: So replace myInfo { "plusActive":true; } with plusActive = true; You shouldn't need to run any sort of a function, assuming the variable in question is not read until the page is loaded (which is far from certain).

Categories : Misc

GreaseMonkey @include for about:newtab
See the docs at "Include and exclude rules, Extra schemes". for a script to run on blank tabs, you must now explicitly set @include about:blank. For example: // ==UserScript== // @name _Very noisy script // @include about:blank // @include * // ==/UserScript== alert ("Fire on blank"); However, Firefox now uses about:newtab by default, and Greasemonkey currently doesn't consider about:newtab to be "Greaseable". (It should though, and I'll look into getting a pull-request accepted for this.) So, to get scripts firing on blank tabs, you currently must set those blank tabs back to using about:blank. Do that by opening about:config and setting browser.newtab.url to about:blank.

Categories : Javascript

Preventing pop-up box from being displayed using Greasemonkey
A Greasemonkey question is probably better asked over at userscripts.org Anyways... it seems like you just want to hide elements. CSS is probably the best way. There's a cool extension called Stylish that does this really well. Just use normal FF tools or Firebug to inspect what element pops up and try, using CSS rules, to hide it with Stylish. It's better that way, because dealing with Gmail using JavaScript could be really frustrating.

Categories : Javascript

How to set the swf path of TableTools when using it with Greasemonkey
If one examines the source code of dataTables.Tabletools.js, while initializing a datatable, tabletools uses the TableTools.DEFAULTS objects and combines them with your tables custom settings. At line no 1158 , as per the version (1.0.4-Tabletools2) that i have, the code sets the moviePath for ZeroClipboard_TableTools, which i am assuming, is a singleton. Now if you have multiple tables on the page, this object ends up taking the value of swfpath specified for the last table , or Default "sSwfPath": "../swf/copy_csv_xls_pdf.swf" , if not specified. /* Flash file location */ this.s.swfPath = this.s.custom.sSwfPath; if ( typeof ZeroClipboard_TableTools != 'undefined' ) { ZeroClipboard_TableTools.moviePath = this.s.swfPath; } So, i c

Categories : Misc

greasemonkey currency converter
You need to recurse or loop through just the nodes that have the dollar values. Never use replace() or RegExp on .html() or innerHTML. Not only will this trash the target page, but you will have a devil of a time getting the desired results. Recurse through the page using DOM methods. Note that currency values come in many formats, so converting them can get complex. Here's moderately robust code for the whole page (sans iframes) You can see it in action at jsFiddle: // ==UserScript== // @name _Global currency converter, dollars to rupees // @include http://YOUR_SERVER.COM/YOUR_PATH/* // @grant GM_xmlhttpRequest // ==/UserScript== GM_xmlhttpRequest ( { method: "GET", url: 'http://rate-exchange.appspot.com/currency?from=USD&to=INR', //Google sends m

Categories : Javascript

JavaScript: Need functions to convert a string containing binary to hex, then convert back to binary
Try this jsfiddle. The more interesting functions to you are here. Not necessarily the cleanest or most efficient ones, but yea: // converts binary string to a hexadecimal string // returns an object with key 'valid' to a boolean value, indicating // if the string is a valid binary string. // If 'valid' is true, the converted hex string can be obtained by // the 'result' key of the returned object function binaryToHex(s) { var i, k, part, accum, ret = ''; for (i = s.length-1; i >= 3; i -= 4) { // extract out in substrings of 4 and convert to hex part = s.substr(i+1-4, 4); accum = 0; for (k = 0; k < 4; k += 1) { if (part[k] !== '0' && part[k] !== '1') { // invalid character return { valid: fa

Categories : Javascript

How do I find out when a tab I've opened with greasemonkey is loaded?
I found a way around the problem... oddly enough, I couldn't do it when using GM_openInTab to create the window, but using mywin2=window.open("http://www.aywas.com/message/notices/9801049/", "my_win2"); allowed me to use the following code to detect the load and close the tab only after it was loaded enough for my purposes! (Although the 'window title' bit of that code above didn't seem to do anything...) mywin2.addEventListener('load', function() { mywin2.close() }, false);

Categories : Javascript

greasemonkey simple string manipulation
var url = "www.something.com/item/4563/"; var matches = url.match(/item/(d+)/); var itemNumber = matches && parseInt(matches[1], 10); console.log(itemNumber); // => 4563

Categories : Misc

How to use userscripts in a site?(How does Greasemonkey work)
Greasemonkey and Userscripts.org are meant to provide kind of lightweight extensions for the browser, not for the webpages. I.e. you install them as the user inside your browser. Some of the trivial scripts might be incorporated into webpages, but in general, Greasemonkey has some "superpowers" to do things that ordinary JavaScript can't do due to security constraints. For instance, issuing (and reading response of) cross-domain XMLHttpRequest, interactions between frames from different origin etc. Normally Greasemonkey scripts are executed when DOMContentLoaded is fired by the browser (this can be changed using @run-at directive to execute the script before anything is loaded). If the script has @grant none in its GM meta section, then it could be perhaps incorporated into your site, b

Categories : Javascript

Only target non-active buttons with Greasemonkey
Try this: waitForKeyElements ("a.action-button:not(.active)", triggerMostButtons); The first parameter here works like a jquery selector. It finds: "a" tags (a) with a class of "action-button" (.action-button) without a class of "active" (:not(.active)) Note that the "." character is CSS notation for a class identifier. Here's the jquery reference for "not": http://api.jquery.com/not-selector/

Categories : Javascript

Convert jQuery UI colorpicker slider to jQuery Mobile version
Working example: http://jsfiddle.net/Gajotres/7F9eZ/ HTML : <!DOCTYPE html> <html> <head> <title>jQM Complex Demo</title> <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/> <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=no; target-densityDpi=device-dpi"/> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" /> <!--<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>--> <script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script> </head> <body> <div data-r

Categories : Jquery

Calling a local WCF service via Scriptish or Greasemonkey
I figured out how to do it via a GET request thanks to M.Babcock for pushing me in that direction (unimportant parts intentionally left out to save space). Service.svc: [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] public class Service : IService { [WebGet(ResponseFormat = WebMessageFormat.Json)] public bool MatchPartial(string partialFilename) { ... } } Web.config: <configuration> ... ... <system.web> <compilation debug="true" targetFramework="4.5" /> <httpRuntime targetFramework="4.5" /> </system.web> <system.webServer> <httpProtocol> <customHeaders> <!-- IMPORTANT FOR THIS TO WORK USING JQUERY GET OR AJA

Categories : C#

Watch for element creation in greasemonkey script?
MutationObservers are called for more things than just adding nodes, including changes to attributes and removing nodes. So watch out for mutation.addedNodes returning null - in which case this code will fail. Try: if (mutation.addedNodes && mutation.addedNodes[0].getAttribute('class') === 'nav') { ... The mutation object also has a 'type' attribute that you can use to get more info; have you read the API docs on MDN? There are some good examples there.

Categories : Javascript

How to transform an XML file with XSLT, using a Greasemonkey script?
I would have added this in a comment, but I don't have the relevant reputation. There are two things that I would check. Especially if this is working on a string, and not a file from the server like you said Make sure that what you are getting from the server is a string, and not an object Make sure the xml you are getting from the server is correct. If you aren't getting a string, you can do an ajax request to get the text from the xml. And then load that as your new xml var. And if you really just wanted to make your xml user friendly, I would suggest checking out http://code.google.com/p/vkbeautify and http://google-code-prettify.googlecode.com/svn/trunk/README.html Those should maintain the xml format while stylizing it to make it easy to read. Plus, you won't have to mess with

Categories : Javascript

Greasemonkey script does not load external JS and CSS file
That linked answer was from 2011, and Greasemonkey has changed a lot since then. (Note, I just now updated that answer to reflect the changes.) Basically, you need to use @grant directives now. If you looked on Firefox's error console (CtrlShiftJ), you might have seen error messages like: GM_addStyle is not defined Here is a bare-bones addition of jQuery-UI to demonstrate the process: // ==UserScript== // @name _YOUR_SCRIPT_NAME // @include http://YOUR_SERVER.COM/YOUR_PATH/* // @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js // @require http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js // @resource jqUI_CSS http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css // @grant GM_addStyle // @grant GM_getResou

Categories : Javascript

Including a Greasemonkey script across multiple domains
Reference: Greasemonkey Include and exclude rules Match Patterns Match patterns and globs The solutions that work on Greasemonkey (which is Firefox), may be different on Chrome and on Tampermonkey. Three basic approaches: Use 30 different @include lines: While this may be unpalatable in terms of cut-and-paste coding, it is the one approach that will work the same across browsers and the one that will have the best browser performance. The other approaches require the browser to do (more) checks against possibly every page or iframe visited. Use a regex @include: @include /^http://(1stDomain.com|2ndDomain.com|3rdDomain.net|etc.)/(admin/edit|blog|user/.+?/history)/ This is one line, and performs fairly well, but the line can get unwieldy, and this will only work on Greasemonkey an

Categories : Misc

Greasemonkey renaming texts from array only works once
for(var i = 0; i<(array.length-1); i=i+2) Might be part of your problem... The array length is 4.... you start counting at 0 which means that you only go to 3 on the list (I think), and then i=i+2 means that you are only processing every other one (I think).. try for(var i = 0; i<(array.length-1); i=i++) or for(var i = 0; i<(array.length); i=i++) Wait.......... when it executes does it show the first array value or the last? It may be looping too fast to see all of them, since you are replacing one with the next

Categories : Arrays

Greasemonkey script seems to execute lines out of order
Try this .. setTimeout(function(){$("#cat_1").attr("checked",true);},0); If it is a race condition of some kind this will put your command at the bottom of the stack.

Categories : Javascript

Click many links, in one page, with a Greasemonkey script?
var all = document.getElementsByClassName("delete"); for(var i=0; i<all.length; i++) { var deleteUrl = all[i].href; var ifr = document.createElement("IFRAME"); document.body.appendChild(ifr); ifr.src = deleteUrl; } You could run a simple script like the above in the browser's JavaScript console or make it a bookmarklet.

Categories : Javascript

How can I save greasemonkey outputs across numerous tabs
Most UserScript environments provide the very useful GM_setValue and GM_getValue functions. You do have to be careful about race conditions though, so I would be tempted to have each tab generate a random number (perhaps based on time) and then put their stuff in a key based upon that value. Then, at the end, concatenate the strings together and display one large string at the end that can be cut-and-pasted. Or, if you'd rather not cut-and-paste, you can generate a massive string and use the HTML5 download attribute. Edit, based on OP's comment (Typed on the fly, untested.) // The documentation talks about the second parametere here -- a default value. var value = GM_getValue("value", ""); value += str + " "; GM_setValue("value", value); While all UserScript methods should underst

Categories : Javascript

Prevent Greasemonkey script from inserting div into iframe
if ( window.self === window.top ) { not in a frame } else { in a frame } check the above condition first before your code of inserting div original link: How to identify if a webpage is being loaded inside an iframe or directly into the browser window?

Categories : Javascript

How to change the default metadata in new Greasemonkey scripts?
I see you have already opened a feature request, which is the correct way to handle this long term. For a quick-and dirty, temporary fix -- that will work only for you and only until the next Greasemonkey update, you can do the following: Shut down Firefox. Find your Firefox profile folder. To be extra safe, save a backup copy of your profile folder. Find the Greasemonkey extension package. It will be in the extensions sub folder and is normally named {e4a8a97b-f2ed-450b-b12d-ee082ba24781}.xpi. Using a zip-file tool, like 7-Zip, open the .xpi file. Find and extract content ewscript.js. Just before line 124, script.push("// @version 1");, add the following lines: script.push("// @require http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"); script.push("// @author

Categories : Jquery

How to convert custom jquery.min file to jquery for development
Minification often changes the names of variables, combines files, and makes optimizations. A program can't guess at variable names, decide where files should be split, and (shouldn't) make your code perform worse. Indentation You can have your code properly indented by using a service like jsbeautifier. Variable Names Using an editor, like WebStorm, you can refactor variable names. This means that you select one variable, change the name, and anywhere else it's referenced will also have the new name. It might take a bit. Splitting Files This can be done by hand fairly easily. I recommend an editor with tabs to make it less painful.

Categories : Jquery



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.