userscripts

Can a greasemonkey-type userscript be packaged as a Chrome extension?

跟風遠走 提交于 2019-11-28 17:54:38
Today Google changed the way userscripts are installed in Chrome . No longer can you just click on a link that contains one, confirm a couple dialog boxes and have it installed. Now you have to download the script with Save As..., open the Finder/Explorer window that contains it, open the Extensions window in Chrome, then drag the script to the extensions window. IOW, a big PITA. Presumably the alternative is to package as a Chrome extension and get it on the Chrome webstore. However, I can't find any information anywhere that suggests you can package a userscript as an extension. Is this

How to replace lots of words in AJAX-driven page text, and in select attributes — using a Tampermonkey script?

爱⌒轻易说出口 提交于 2019-11-28 14:23:49
I'm translating text/words/terms inside an HTML document using a tree walker to affect only text nodes: var replaceArry = [ [/View your user account/gi, 'Tu cuenta'], // etc. ]; var numTerms = replaceArry.length; var txtWalker = document.createTreeWalker ( document.body, NodeFilter.SHOW_TEXT, { acceptNode: function (node) { //-- Skip whitespace-only nodes if (node.nodeValue.trim() ) return NodeFilter.FILTER_ACCEPT; return NodeFilter.FILTER_SKIP; } }, false ); var txtNode = null; while (txtNode = txtWalker.nextNode () ) { var oldTxt = txtNode.nodeValue; for (var J = 0; J < numTerms; J++) {

window.load doesn't fire always on chrome?

前提是你 提交于 2019-11-28 12:45:30
I have this userscript: // ==UserScript== // @name test // @namespace test // @description show's an alert on load // @include http://* // @include https://* // ==/UserScript== window.addEventListener('load', function(){alert("loaded");}, false); This works fine on Firefox on all pages but doesn't work at all on Chrome at some occasions. One example is this website: http://lexin.nada.kth.se/lexin/ Entering the link in the address and hitting enter, loads the page normally but no alert is popped up. If you press F5 to refresh the page, the popup appears. Is there some explanation to this weird

Why doesn't this userscript work on Facebook?

自作多情 提交于 2019-11-28 11:40:52
问题 I was writing user script for Google Chrome that would automatically open a specific chat tab, but it's not working, I think that it is because the Chat.openTab is not specifically defined, because when i run the code in the javascript console it works fine. CODE: var face = "facebook.com" var domain = document.domain if (domain = face) { Chat.openTab("sam.sebastian1", "Seb") } 回答1: The other answers point out that it should be (domain == face) , and this is an error. However, it is not what

How to change the name field of an <input> in an AJAX-driven page?

北慕城南 提交于 2019-11-28 10:36:53
问题 For this target page (Sorry but SO doesn't allow hyperlinks to 62.0.54.118): http://62.0.54.118/search?&q=42&oq=42&sourceid=chrome&ie=UTF-8&filter=0 , I want to change the name field of an <input> by default with a userscript. The input is: <input class="gsfi" id="lst-ib" name="q" maxlength="2048" value="42"...> I want to change it to: <input class="gsfi" id="lst-ib" name="&q" maxlength="2048" value="42"...> That is, I Want to change the q into &q in the name field of the input by default. I

Chrome userscript fires on all pages despite @match and @include settings

China☆狼群 提交于 2019-11-28 07:56:21
问题 I use match to restrict my script to work only one domain but chrome runs it in every domain. I tried @include and @match and it says "Access your data on all websites" when I try to install it and it runs it in all websites. How can I restrict userscript to one domain in chrome? Metadata is same as this page: http://www.chromium.org/developers/design-documents/user-scripts I mean it's: // @match http://*.google.com/* // @match http://www.google.com/* 回答1: Note: this answer developed between

How to convert a bookmarklet into a Greasemonkey userscript?

余生颓废 提交于 2019-11-28 07:50:11
Is there a easy way to do this. And is there anything that needs to be changed due to differences in how it is ran? Brock Adams The easiest way to do this: Run the bookmarklet code through a URL decoder . so that javascript:alert%20('Hi%20Boss!')%3B , for example, becomes: javascript:alert ('Hi Boss!'); Strip the leading javascript: off. Result: alert ('Hi Boss!'); Add this code to the end of your Greasemonkey file. For example, create a file named, Hello World.user.js , with this code: // ==UserScript== // @name Hello World! // @description My first GM script from a bookmarklet // @include

Get 2 userscripts to interact with each other?

这一生的挚爱 提交于 2019-11-28 01:21:38
I have two scripts. I put them in the same namespace (the @namespace field). I'd like them to interactive with another. Specifically I want script A to set RunByDefault to 123. Have script B check if RunByDefault==123 or not and then have script A using a timeout or anything to call a function in script B . How do I do this? I'd hate to merge the scripts. The scripts cannot directly interact with each other and // @namespace is just to resolve script name conflicts. (That is, you can have 2 different scripts named "Link Remover", only if they have different namespaces.) Separate scripts can

Native javascript equivalent of jQuery :contains() selector

陌路散爱 提交于 2019-11-27 22:55:48
I am writing a UserScript that will remove elements from a page that contain a certain string. If I understand jQuery's contains() function correctly, it seems like the correct tool for the job. Unfortunately, since the page I'll be running the UserScript on does not use jQuery, I can't use :contains(). Any of you lovely people know what the native way to do this is? http://codepen.io/coulbourne/pen/olerh elclanrs This should do in modern browsers: function contains(selector, text) { var elements = document.querySelectorAll(selector); return [].filter.call(elements, function(element){ return

Downloading an image using XMLHttpRequest in a userscript

烂漫一生 提交于 2019-11-27 19:50:38
First of all there is a question with the same title here on SO but its not what I'm looking for and it doesn't have a complete answer either. So here's my question. Say I have this URL which directs to an image. https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash4/299595_10150290138650735_543370734_8021370_355110168_n.jpg Once I put this parameter ?dl=1 to the end of the URL, it becomes downloadable. https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash4/299595_10150290138650735_543370734_8021370_355110168_n.jpg?dl=1 I'm trying to do this task through a userscript. So I used XMLHttpRequest for