honglei92
V2EX  ›  Android

安卓注入 js 文件的话, js 文件有什么要求呢,里面的内容有什么格式呢?

  •  
  •   honglei92 · Feb 11, 2020 · 13509 views
    This topic created in 2342 days ago, the information mentioned may be changed or developed.

    之家用字符串加载 是可以的 ,但是 js 文件长了的话不方便

    3 replies    2020-02-22 14:43:19 +08:00
    honglei92
        1
    honglei92  
    OP
       Feb 13, 2020
    (function(){let html = document.querySelector('.active_header').innerHTML;window.onload = function(){ var myVideo = document.getElementsByTagName('video')[0];myVideo.addEventListener('play',function(){console.log('播放');document.querySelector('.active_header').innerHTML = html + '播放';window.localStorage.setItem('play_time','10');});myVideo.addEventListener('pause',function(){console.log('暂停');document.querySelector('.active_header').innerHTML = html + '暂停';});}})()


    这样的就格式可以了,( function(){.....}()) ,然后里面的内容普通压缩一下。
    honglei92
        2
    honglei92  
    OP
       Feb 21, 2020
    js 注入的话,长度超过限制 你们是怎么处理的呢。x5 内核是限制是 1M
    ByteRan
        3
    ByteRan  
       Feb 22, 2020
    JS 里面动态在加载 JS
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2512 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 00:25 · PVG 08:25 · LAX 17:25 · JFK 20:25
    ♥ Do have faith in what you're doing.