Chrome extension - retrieving global variable from webpage

后端 未结 5 1746
离开以前
离开以前 2020-11-22 17:10

I am working on an extension for Chrome. I wish parse the content of the \"original\" Gmail message (the currently viewed message).

I tried to utilize the jQuery.loa

5条回答
  •  一个人的身影
    2020-11-22 17:54

    I had a slightly different approach based on your extension's accessible html pages.

    Add your page to the manifest:

    "web_accessible_resources": ["variables.html"]

    Create your page (here, variables.html) and extract the content's data (i.e. window.contentVar):

    
    

    Access from your extension's JavaScript:

    var myVarName = $("#my-var-name").text();

提交回复
热议问题