You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

i0.js 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. console.log("_e I.js")
  2. console.log("_e ")
  3. console.log("_e ....z",localStorage)
  4. clog = console.log
  5. glob_u= window.glob_u|| {}
  6. function lsto_event(){
  7. clog("page-lsto_event:",arguments,this)
  8. }
  9. function rec_on_page(e){
  10. // clog("jx rec_on_page",arguments,this)
  11. // if (e.PAGE_MC_INIT)
  12. }
  13. function send_from_page(){
  14. window.postMessage({"type":"FROM_PAGE",o:{a:1}})
  15. }
  16. function port_msg_1(){
  17. clog("_jx port_msg_1",arguments,this)
  18. }
  19. function port_msg_err_1(){
  20. clog("_jx port_msg_err_1",arguments,this)
  21. }
  22. function dec_info(fn,err,args,that){
  23. var s = err.stack.split("\n")[2]
  24. // var err = new Error()
  25. inc_vx(glob_u.trc.m,err.stack)
  26. inc_vx(glob_u.trc.m2,s)
  27. // clog(err.stack,err)
  28. // clog("DEC:",fn.name,s,[err],args,that)
  29. }
  30. function dec_json(fn){
  31. // clog(fn,[fn])
  32. return function(){
  33. var err =new Error()
  34. var s= dec_info(fn,err,arguments,this)
  35. let ret = fn(...arguments)
  36. if (fn.name.includes("wJSON")){
  37. clog("DEC:",fn.name,s,ret,[err],arguments,this)
  38. }
  39. // clog("DEC:",fn.name,s,[err],arguments,this)
  40. // clog("DEC:",fn.name,s,ret,[err],arguments,this)
  41. return ret
  42. return fn(...arguments)
  43. }
  44. }
  45. function init_page_mc(){
  46. glob_u.m_ch = new MessageChannel();
  47. var channel = glob_u.m_ch
  48. var port1 = channel.port1
  49. port1.onmessage = port_msg_1
  50. port1.onmessageerror = port_msg_err_1
  51. // postMessage({"type":"CS_MC_INIT",o:{port1}})
  52. postMessage("PAGE_MC_INIT", "*", [
  53. channel.port2
  54. ]);
  55. }
  56. function q_run_once(){
  57. if (glob_u.init){return}
  58. glob_u.init=1
  59. glob_u.trc={
  60. m:new Map(),
  61. m2:new Map(),
  62. }
  63. glob_u.JSON = {
  64. parse:JSON.parse,
  65. stringify:JSON.stringify,
  66. isRawJSON:JSON.isRawJSON,
  67. rawJSON: JSON.rawJSON,
  68. }
  69. JSON.parse = dec_json(JSON.parse)
  70. JSON.stringify = dec_json(JSON.stringify)
  71. JSON.isRawJSON = dec_json(JSON.isRawJSON)
  72. JSON.rawJSON = dec_json(JSON.rawJSON)
  73. window.addEventListener('storage', lsto_event)
  74. window.addEventListener('message', rec_on_page)
  75. window.addEventListener('storage', lsto_event)
  76. }
  77. q_run_once()
  78. function jdec(n,s){
  79. clog("JDEC",[n,s])
  80. var JSON_fn = function JSON_fn(){
  81. // var ret = JSON[n]
  82. var ret = JSON[n](...arguments)
  83. // return JSON[n](...arguments)
  84. // clog(n,s,ret,arguments)
  85. return ret
  86. }
  87. JSON[n] = JSON_fn
  88. return JSON_fn
  89. }
  90. // jdec("stringify","z")
  91. /*
  92. jdec("parse","z")
  93. jdec("isRawJSON","z")
  94. jdec("rawJSON","z")
  95. */
  96. clog("~~~~~~~~~~~`2")
  97. // function init_page_mc(){}