bookmarklet

Load external JS from bookmarklet?

只谈情不闲聊 提交于 2019-11-27 05:06:10
问题 How can I load an external JavaScript file using a bookmarklet? This would overcome the URL length limitations of IE and generally keep things cleaner. 回答1: 2015 Update Content security policy will prevent this from working in many sites now. For example, the code below won't work on Facebook. 2008 answer Use a bookmarklet that creates a script tag which includes your external JS. As a sample: javascript:(function(){document.body.appendChild(document.createElement('script')).src='** your

How to convert a bookmarklet into a Greasemonkey userscript?

空扰寡人 提交于 2019-11-27 02:00:16
问题 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? 回答1: 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: // =

Copy text to clipboard from bookmarklet

天大地大妈咪最大 提交于 2019-11-27 01:23:10
问题 I'm trying to write a little bookmarklet that can extract some text from the active page and load that into the clipboard. The extraction is easy enough, but I'm really stuck doing the clipboard-copying part. Currently, I'm just alert ing the text and hitting Ctrl + C to copy the text from the message-box, which isn't ideal. I've read How to Copy to Clipboard in JavaScript and other questions that suggest I use zeroclipboard, but I have no idea how one would make that work from a bookmarklet

Find all instances of 'old' in a webpage and replace each with 'new', using a javascript bookmarklet

浪子不回头ぞ 提交于 2019-11-27 01:02:58
问题 What I want to do is replace all instances of 'old' in a webpage with 'new' in a JS bookmarklet or a greasemonkey script. How can I do this? I suppose jQuery or other frameworks are okay, as there're hacks to include them in both bookmarklets as well as greasemonkey scripts. 回答1: A function that is clobber-proof. That mean's this won't touch any tags or attributes, only text. function htmlreplace(a, b, element) { if (!element) element = document.body; var nodes = element.childNodes; for (var

Reverting CSS style of <input type=submit button to its default style

ぃ、小莉子 提交于 2019-11-26 22:57:48
问题 I'm using a bookmarklet that inserts a script tag into the current web page. This script has some UI and an " input type=submit.... " tag in it. Web page A has chosen not to style " input type=submit.. " tags whereas web page B has styled them. This results in the bookmarklet displaying differently styled submit buttons based on the underlying page's style. I want the submit buttons to be styled identically on all web pages in its default manner . One solution is to set the CSS style for the

How to have favicon / icon set when bookmarklet dragged to toolbar?

混江龙づ霸主 提交于 2019-11-26 18:47:47
问题 I've made myself a bookmarklet, and it functions just fine, but when added to a toolbar in Opera or Firefox, it just takes on the default bookmark icon for the browser (a globe and a star, respectively). My site has a favicon, and the window, tab and even [site] bookmark uses the favicon I've specified. Just not my bookmarklet. How can I code my site or bookmarklet so that the bookmarklet gets the favicon, too? I'm aware of various manual hackery techniques users can use to set the favicon

Does execCommand SaveAs work in Firefox?

百般思念 提交于 2019-11-26 17:53:34
Why does this not work in ff/chrome? javascript: document.execCommand('SaveAs','true','http://www.google.com'); (used as a bookmarklet) execCommand is not completely standardized across browsers. Indeed, execCommand('SaveAs', ...) only seems to be supported on IE. The recommended way to force a save-as would be to use a content-disposition: attachment header, as described in http://www.jtricks.com/bits/content_disposition.html Since this is part of the HTTP header, you can use it on any file type. If you're using apache, you can add headers using the .htaccess file, as described here . For

How can I get the element in which highlighted text is in?

China☆狼群 提交于 2019-11-26 16:35:39
问题 I am trying to learn how to write a bookmarklet where I can highlight some text, click on the bookmarklet and have it tell me what got highlighted. I can get that far, but next I want to know what element that text is in. For example: <div id="some-id">to be highlighted</div> The bookmarklet code: javascript:(function(){alert(window.getSelection();})() If I highlight the text "to be highlighted" and then click on the bookmarklet, it will alert the text. But how can I get the element in which

Change CSS of selected text using Javascript

那年仲夏 提交于 2019-11-26 13:29:05
I'm trying to make a javascript bookmarklet that will act as a highlighter, changing the background of selected text on a webpage to yellow when the bookmarklet is pressed. I'm using the following code to get the selected text, and it works fine, returning the correct string function getSelText() { var SelText = ''; if (window.getSelection) { SelText = window.getSelection(); } else if (document.getSelection) { SelText = document.getSelection(); } else if (document.selection) { SelText = document.selection.createRange().text; } return SelText; } However, when I created a similar function to

JavaScript: Invert color on all elements of a page

随声附和 提交于 2019-11-26 11:53:30
问题 Note: I am keeping an up-to-date version of the bookmarklet in my question which works well and is based on Jacob\'s answer. If you are looking for a bookmarklet to use, use that one. See leosok\'s fantastic answer if you just want something amazing that works on chrome. I want to be able to invert the color of all the elements on a page with a JavaScript bookmarklet. I know that to invert a color you subtract each of the RGB hex values from 255(xFF), but beyond that I am unsure of how to