javascript-injection

CefSharp Inject Javascript prior to any document load/processing

假如想象 提交于 2021-02-05 20:30:54
问题 For a project I am working on I need to inject javascript prior to any of the webpage document processing begins. This can easily be achieved via the WebBrowser component, but I am encountering difficulty using CefSharp. Here is a simplification of the problem, a webpage needs an "InjectedObject" to be present to function. Calling the webpage without injection occurring at the very top of the document, or being evaluated/executed before the document is processed would result in: =====html

Inject javascript code into anonymous function scope

天涯浪子 提交于 2020-05-09 17:12:32
问题 I've got this kind of script I need to inject into ! function(e) { function doSomething() { } } Basically I get a reference to doSomething, when my code is called via Function object, but I need to hook to doSomething, so I need an original reference to id. Since doSomething is declared inside anonymous function I can't get to it. Question is, can I somehow inject code into the scope of anonymous function, Greesemonkey or any other tool. 回答1: Javascript doesn't make it easy to get values from

Can't insert js programmatically if it uses document.write

假如想象 提交于 2020-01-30 06:28:46
问题 I am trying to insert js files programmatically, using jquery and something like this: var script = document.createElement( 'script' ); script.type = 'text/javascript'; script.src = 'http://someurl/test.js'; $('body').append(script); It works fine, if test.js contains an alert or some simple code it works fine, but if the file test.js contains document.write , and the file including the js is hosted on another domain than test.js (or localhost), nothing happens and firebug shows the error : A

Can't insert js programmatically if it uses document.write

我的梦境 提交于 2020-01-30 06:28:08
问题 I am trying to insert js files programmatically, using jquery and something like this: var script = document.createElement( 'script' ); script.type = 'text/javascript'; script.src = 'http://someurl/test.js'; $('body').append(script); It works fine, if test.js contains an alert or some simple code it works fine, but if the file test.js contains document.write , and the file including the js is hosted on another domain than test.js (or localhost), nothing happens and firebug shows the error : A

Is there a known workaround for IE9's execution order of injected script tags?

試著忘記壹切 提交于 2019-12-30 11:06:07
问题 I am sure I don't fully understand this problem, but it seems that we are seeing strange behavior on IE9 on my project, somehow related to out-of-order execution of JavaScript that has been injected via calls to document.write , e.g.: document.write('<scr'+'ipt type="text/javascript" src="'+file1+'"></src'+'ipt>'); document.write('<scr'+'ipt type="text/javascript" src="'+file2+'"></src'+'ipt>'); document.write('<scr'+'ipt type="text/javascript" src="'+file3+'"></src'+'ipt>'); My limited

Is there a known workaround for IE9's execution order of injected script tags?

扶醉桌前 提交于 2019-12-30 11:06:05
问题 I am sure I don't fully understand this problem, but it seems that we are seeing strange behavior on IE9 on my project, somehow related to out-of-order execution of JavaScript that has been injected via calls to document.write , e.g.: document.write('<scr'+'ipt type="text/javascript" src="'+file1+'"></src'+'ipt>'); document.write('<scr'+'ipt type="text/javascript" src="'+file2+'"></src'+'ipt>'); document.write('<scr'+'ipt type="text/javascript" src="'+file3+'"></src'+'ipt>'); My limited

Lib to protect SQL/javascript injection for java/jsp

自古美人都是妖i 提交于 2019-12-24 02:38:08
问题 Anyone know a good lib where i can run the strings before they are inserted, that can strip out sql/javascript code? To be run in jsp pages. Idealy the lib would be: Free Lightweight Easy to use Thanks in advance to the SO community who will happily reply :) 回答1: Apache Commons lang StringEscapeUtils will get you some of the way. It escapes, doesnt strip. http://commons.apache.org/lang/api/org/apache/commons/lang/StringEscapeUtils.html Edit: Escaping can save you from injection attacks

In modern browsers, is there any security limitation for JavaScript bookmarklets?

大城市里の小女人 提交于 2019-12-24 00:29:22
问题 I read an article about bookmarklets which says that bookmarklets are so powerful they can be dangerous. For example, a malicious bookmarklet can collect your "cookies", "localStorage", the string in the password input box and then send it to a remote server, which is similar to "script injection". I'm curious about that. Since this article was written in 2007 (8 years ago), is there any limitation for bookmarklets (as well as browser plugins) to improve the security in modern browsers? 回答1:

Browser extensions: how can injecting javascript code into a page work without conflicts?

我的未来我决定 提交于 2019-12-23 12:46:30
问题 I have started developing browser extensions. I noticed a common concept is that the extension can inject JS code into the current browser tab. I am a bit puzzled of how that doesn't cause issues on a regular basis. I mean, how can things still work if I inject version x of JQuery (through my browser extension) in a page that has already included version y of JQuery? Won't there be a conflict for the $() function? How is it possible things go that smoothly? Is there any particular technique

How safe is client-side HTML Sanitization?

扶醉桌前 提交于 2019-12-18 15:49:24
问题 I have been looking at Pagedown.js lately for the allure of using mark-down on my pages instead of ugly readonly textareas. I am extremely cautious though as it seems easy enough to dupe the sanitized converter. I have seen some discussion around Angular.js and it's html bindings and also heard something when Knockout.js 3.0 came out that there had been a previous unsafeness to the html binding. It would seem all someone would need to do to disable the sanitizer in Pagedown.js for instance is