Extracting JSON from string using regex
Use .exec to match a group
Add comma removed by slice directly into the regexp
Use capturing groups: query for [1], not for [0]




let script = document.getElementById('source').text;
var result = /item:(.*|[\s\S]*),\s*onSelected/gm.exec(script)[1];
console.log(JSON.parse(result));
&lt;script id="source" type="text/plain"&gt;
jQuery(function($) {
      
        new Selector('itemSelect', {
          item: {"id":9343513159,"title":"The thing","description":"\u003cp\u003eThis is the description\u003c\/p\u003e\n\u003cp\u003eIt has details\u003c\/p\u003e\n","published_at":"2016-12-10T10:08:00-05:00","available":true,"individuals":[{"id":34972221767},{"id":34972221768},{"id":34972221769}],"images":["\/\/cdn.site.com\/s\/files\/1\/0094\/2252\/items\/image.jpg?v=1481382473"],"options":["Time"],"content":""},
          onSelected: selectCallback,
          enableState: true
        });
      
    
       // Some stuff here
      
        $('.main:eq(0)').prepend('&lt;label class="forever" for="time"&gt;Forever&lt;/label&gt;');
      
    });
    
    window.mainItem = window.mainItem || {};
    
    mainItem.variables = {
      available : false
    };
    
    (function() {
      if (true) {
        mainItem.variables.available = true;
      }
    })()
&lt;/script&gt;