0

Hi I am new in jquery and javascript. Please help me to extract date from below code / function.

Below is the script section:

<script type="application/javascript">
  var c1x = {};
  c1x.cid = "63401";
  c1x.pageType = "PDP";
  c1x.productID =  "120367970";
  c1x.tileCount = 6;
  c1x.async = true;

or from below script tag present in the page source code.

    <script type="text/javascript">        
  var m_id = 453;
    </script>        

    <script type="text/javascript">
  var l_id = 63401;
    </script>        

I am trying to make chrome extention to extract productid and cid of every page. For reference below is the Main web page link

Amit
  • 23
  • 7
  • What is the end result you want and could you please add the code you've tried so far? You should just be able to access them via `window.c1x.cid` etc. – Joe Aug 11 '17 at 09:05
  • I want to alert or popup the CID and PID value from the HTML page. Currently looking for the exact code to extract the data from page so the I can implement . I am sorry till now I have not created any code.. But tried document.getElementsByTagName("script") and alert(document.getElementsByClassName('pID')[0].innerHTML); – Amit Aug 11 '17 at 09:07
  • Ok, that's definitely not going to work as you're trying to select a javascript object like a HTML element. Try not to use `alert` in the final code but this should work for now: `alert(window.c1x.cid);`. I'd also strongly recommend looking at some intro to web development tutorials as otherwise you're going to run into a lot of issues. – Joe Aug 11 '17 at 09:14
  • @Joe Please help me to extract data from – Amit Aug 11 '17 at 09:17
  • The exact same way in my comment above, `window.m_id`. – Joe Aug 11 '17 at 09:18
  • Thank you so much @Joe Will also check web development tutorials R&D. – Amit Aug 11 '17 at 09:23
  • Plugins cannot talk to web page javascript directly. They need to talk via [messages](https://developer.chrome.com/extensions/messaging). You need to inject some javascript on page load to scrap the id from the web page and can extract it via messaging. Please refer [here](https://stackoverflow.com/a/11696154/4073386) – Siddhant Patra Aug 11 '17 at 09:27
  • Thanks @SiddhantPatra – Amit Aug 11 '17 at 09:33

0 Answers0