[JavaScript] Object-Oriented Verbosity and Obfuscation #326
MasterInQuestion
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
[ Quote Eruda "README.md" # Demo (@ CE 2023-05-01):
https://github.com/liriliri/eruda#demo
In order to try it for different sites, execute the script below on browser address bar.
[[
javascript:(function () { var script = document.createElement('script'); script.src="//cdn.jsdelivr.net/npm/eruda"; document.body.appendChild(script); script.onload = function () { eruda.init() } })();
]] ]
According to [ https://developer.mozilla.org/en-US/docs/Web/API/Document/body#browser_compatibility ], "document.body" did not work in Firefox until version 60.
"cdn.jsdelivr.net" seems to redirect HTTP access to HTTPS (via HTTP 301). (so omitting the protocol would be likely pointless; and in some cases erroneous)
Note also: https://github.com/liriliri/eruda/commit/6d3122c99145fa3f5d4e550a4e4d2a8d9944e2b8
"append" also has similar compatibility issues. (and whose usage is not justifiable there)
[[
javascript: void document.getElementsByTagName( "body" )[0].insertAdjacentHTML( "beforeend", "<script src='https://cdn.jsdelivr.net/npm/eruda' onload='eruda.init();'></script>" );
]]
,
[[
javascript: (function () { var x0 = document.createDocumentFragment(); x0.innerHTML = "<script src='https://cdn.jsdelivr.net/npm/eruda' onload='eruda.init();'></script>"; document.getElementsByTagName( "body" )[0].appendChild( x0 ); })();
]]
Such 2 (direct "<script>" injection) may not work, for browsers may for "security considerations" reject such.
[[
javascript: void document.getElementsByTagName( "body" )[0].appendChild( document.createRange().createContextualFragment( "<script src='https://cdn.jsdelivr.net/npm/eruda' onload='eruda.init();'></script>" ) );
]]
[1]
,
[[
javascript: (function () { var x0 = document.createElement( "script" ); x0.src = "https://cdn.jsdelivr.net/npm/eruda"; x0.onload = function () { eruda.init(); }; document.getElementsByTagName( "body" )[0].appendChild( x0 ); })();
]]
,
[[
javascript: (function () { var x0; document.getElementsByTagName( "body" )[0].appendChild( x0 = document.createElement( "script" ) ); x0.src = "https://cdn.jsdelivr.net/npm/eruda"; x0.onload = function () { eruda.init(); }; })();
]]
"
<script ...></script>
" used instead of "<script ... />
", for some parsers that could not even properly recognize XML."
(function () { ... })()
" structure mostly serves as a clumsy scope hint. (preventing "x0" polluting the outer scope)[ [1]
On certain legacy browsers would have to be:
[[
javascript: (function () { var x0 = document.createRange(); x0.selectNode( document.body || ( document.body = document.getElementsByTagName( "body" )[0] ) ); document.body.appendChild( x0.createContextualFragment( "<script src='https://cdn.jsdelivr.net/npm/eruda' onload='eruda.init();'></script>" ) ); })();
]]
Or perhaps doesn't work whatsoever. (Google query: `Chrome "createContextualFragment" error`) ]
Further note on "createContextualFragment":
(mostly unverified, and stale)
[[
Error: NOT_SUPPORTED_ERR: DOM Exception 9
Chrome "createContextualFragment" error "DOM Exception 9"
[ Note on "createContextualFragment":
https://web.archive.org/web/20230329062158/http://vird2002.s8.xrea.com/javascript/document.implementation.createHTMLDocument.html#Note
Firefox v3.6.6 は, createDocument() の第三引数に [object DocumentType] を指定すると, range.createContextualFragment() 実行時にエラー "uncaught exception" が発生する (原因不明). 第三引数に null を指定すればエラーは発生しない.
Google Chrome 5 は, createDocument() の第一引数 (名前空間) に null を指定して生成した [object Document] において, range.createContextualFragment() を実行すると "Uncaught Error: NOT_SUPPORTED_ERR: DOM Exception 9" が発生する (原因不明). createDocument() で第一引数を指定すれば, エラーは発生しない.
Opera v10.60 は, createDocument() で生成した [object Document] において, range.createContextualFragment() を実行するとクラッシュして再起動を要求される. (原因不明) ]
https://github.com/MithrilJS/mithril.js/issues/917#issuecomment-171942079
[[
]]
]]
=== Off-Topic ===
How to disambiguate "一" (numeral 1) from "ー" (Katakana-Hiragana Prolonged Sound Mark)?
What to justify the existence of "ー"..?
See also:
https://en.wiktionary.org/wiki/ー
https://util.unicode.org/UnicodeJsps/character.jsp?a=%E3%83%BC
https://unicode.org/charts/nameslist/n_30A0.html#30FC
Further discussion: https://github.com/MasterInQuestion/talk/discussions/25
Beta Was this translation helpful? Give feedback.
All reactions