bookmarklet

Capture keypress in Javascript (Google Docs)

孤者浪人 提交于 2019-12-21 19:56:55
问题 I'm trying to write a little greasemonkey script/bookmarklet/what have you for Google Docs. The functionality I'd like to add needs a keypress/keyup/keydown event handler (one of those three). Unfortunately, Javascript isn't my forté, and I can't seem to capture (?) a keypress event to while in the edit pane. As a last resort, I've tried the following: javascript:(function(){ els = document.getElementsByTagName("*"); for(i=0;i<els.length;i++){ els[i].onkeypress=function(){alert("hello!");};

How do I create bookmarklet to overlay html/div layer and CSS from external file

风流意气都作罢 提交于 2019-12-21 06:36:13
问题 I'm trying to find a way to create a bookmarklet which will load (from an external file) a new layer/div with other html and css and overlay it on the existing page. Does anyone have a bookmarklet example for this they could share please? I can create the div with the new html content and CSS classes I am just not sure how to write the bookmarklet and javascript/jquery function to load new content on top of the existing page. Thank you very much! 回答1: Try this code, obviously it can be

XmlHttpRequest in a bookmarklet returns empty responseText on GET?

丶灬走出姿态 提交于 2019-12-21 05:16:05
问题 I'm trying to build a javascript bookmarklet for a special URL shortening service we've built at http://esv.to for shortening scripture references (i.e. "Matthew 5" becomes "http://esv.to/Mt5". The bookmarklet is supposed to do a GET request to http://api.esv.to/Matthew+5, which returns a text/plain response of http://esv.to/Mt5 . The code for the bookmarklet itself looks like this (expanded for readability): var body = document.getElementsByTagName('body')[0], script = document.createElement

Content Security Policy for extensions and bookmarklets

不问归期 提交于 2019-12-20 09:54:26
问题 Github has the following Content Security Policy: Content-Security-Policy:default-src *; script-src assets-cdn.github.com www.google-analytics.com collector-cdn.github.com; object-src assets-cdn.github.com; style-src 'self' 'unsafe-inline' 'unsafe-eval' assets-cdn.github.com; img-src 'self' data: assets-cdn.github.com identicons.github.com www.google-analytics.com collector.githubapp.com *.githubusercontent.com *.gravatar.com *.wp.com; media-src 'none'; frame-src 'self' render

How to prevent bookmarklet from loading its result?

筅森魡賤 提交于 2019-12-20 07:37:52
问题 I have a simple bookmarklet for presenting in a prompt() the value of a meta element. It works, but after running the window loads either just the string "null" or the prompted value. How do I prevent the bookmarklet from causing a page load? I just want the script to pop the prompt but do nothing more. My bookmarket is this: javascript:var%20description;var%20metas=document.getElementsByTagName('meta');for(var%20x=0,y=metas.length;x<y;x++){if(metas[x].name.toLowerCase()=="description")

Use Javascript Bookmarklet to Chunk Page Content by Headings

﹥>﹥吖頭↗ 提交于 2019-12-20 04:36:51
问题 I've got an HTML page that is compiled dynamically from a database that I need to restyle and restructure. It looks messy, I know, but what I'm working with is this (note: no <head> or <body> tags): <p>Some paragraph</p> <h1>Heading 1</h1> <p>Some paragraph</p> <p>Some paragraph</p> <h2>Heading 2</h2> <p>Some paragraph</p> <p>Some paragraph</p> <h3>Heading 3</h3> <p>Some paragraph</p> <p>Some paragraph</p> ... I'm trying to code a javascript bookmarklet that will reformat and redivide the

How to inject script into a page using bookmarklet if the Content Security Policy is enabled on the server?

邮差的信 提交于 2019-12-19 04:08:07
问题 I have a bookmarklet which uses jQuery and parses some elements on the page. To use jQuery, i am creating a script tag(with src as the jQuery URL) dynamically and appending to the head tag. This works well for many sites. But, there are few sites like Facebook, for which the bookmarklet is not able to inject the external JS file into the dom.I came to know that this behaviour is because of the response header "Content Security Policy" which prohibits the inclusion of scripts from any other

Javascript get selected text from any textinput/textarea on the page

半城伤御伤魂 提交于 2019-12-18 16:49:20
问题 How can get the selected text from a textbox/textarea if I don't know which one active (focused). I am trying to create a small bookmarklet that will correct the selected text in any type of input on a page. 回答1: For the selection, you want selectionStart and selectionEnd . As for the currently focused element, use document.activeElement . So as a combination you can use: http://jsfiddle.net/rBPte/1/. As Tim Down pointed out, you'd need a more complex solution for Internet Explorer version 8

Find all text nodes

浪尽此生 提交于 2019-12-18 04:37:07
问题 I'm trying to write a bookmarklet that calls the function doSomething(textNode) on all instances of visible text on the document. doSomething() , just for fun, replaces every word with "derp" by replacing the textContent of the textNode passed into it. However, this makes some textNodes that are empty to have words in them, so it breaks the web page. Is there a way to call doSomething() on only every textNode that has words in it? function recurse(element) { if (element.childNodes.length > 0)

Using Javascript to Open a New Page and Populate Form Values There

时光毁灭记忆、已成空白 提交于 2019-12-18 03:49:07
问题 I am using JavaScript in a bookmarklet to populate form elements on a website: javascript:var f = document.forms[0]; f.getElementsByTagName('input')[0].value = 'myname'; f.getElementsByTagName('input')[1].value = 'mypassword'; f.getElementsByTagName('input')[2].click This works. However what I would like to create is a bookmarklet so that it opens the target page, and populates the values there; however it seems that onces the page is loaded, other JavaScript codes are not executed. So, the