在jQuery中获取属性(';标记名';)问题

在jQuery中获取属性(';标记名';)问题,jquery,find,bookmarklet,prop,Jquery,Find,Bookmarklet,Prop,我在使用bookmarklet进行工作时遇到了一些奇怪的设置问题。我需要它能够找到一个页面上的所有视频嵌入,并处理信息,以生成JSON代码插入我们的画廊设置。问题是我无法可靠地获得处理数据所需的信息 首先,我在页面上找到所有具有适当itemprop的div items = $('div[itemprop=video]'); 然后使用$.each()开始处理 thumbnail = getThumb($(this).find('*[itemprop=thumbnailUrl]')); filen

我在使用bookmarklet进行工作时遇到了一些奇怪的设置问题。我需要它能够找到一个页面上的所有视频嵌入,并处理信息,以生成JSON代码插入我们的画廊设置。问题是我无法可靠地获得处理数据所需的信息

首先,我在页面上找到所有具有适当itemprop的div

items = $('div[itemprop=video]');
然后使用$.each()开始处理

thumbnail = getThumb($(this).find('*[itemprop=thumbnailUrl]'));
filename =  getFilename($(this).find('*[itemprop=contentUrl]'));
filelocation = getFilelocation( $(this).find('*[itemprop=contentUrl]'));
我需要能够获取用于处理的thumbnailURL和contentURL

    function getFilename(gfn) {
        if(gfn.prop('tagName') == 'META') {
            gfname = gfn.prop('content');
        } else {
            gfname = gfn.attr('href');
        }
        x = gfname.lastIndexOf('/');
        gfname = gfname.substr(x+1);
        y = gfname.lastIndexOf('.');
        gfname = gfname.substr(0,y);
        return gfname;
    }
.prop('tagName')
不断返回
undefined
itemprops
不在元标记中时,有人知道如何运行此bookmarklet吗

bookmarklet和源代码

编辑:因为有人提到过,我将继续在这里转储bookmarklet代码,去掉多余的gif

    <a href="javascript:(function(){
var jQueryIsReady = function(){  
        if($('#vid2json_container').length < 1)
        {
            container = $(document.createElement('div'));
            container.attr('id','vid2json_container');
            container.css('position','fixed');
            container.css('top','0');
            container.css('left','0');
            container.css('background-color','#222222');
            container.css('padding','2px');
            container.css('border-style','solid');
            container.css('border-width','1px');
            container.css('border-color','#000000');
            container.css('opacity','0.95');
            container.css('z-index','999997');
            container.css('width','500px');
            container.css('height',window.innerHeight);
            container.css('overflow-y','auto');
            container.css('overflow-x','hidden');
            container.hide();

            divider_01 = $(document.createElement('div'));
            divider_01.css('clear','both');

            logo = $(document.createElement('img'));
            logo.attr('src','http://www.cityofdev.com/apps/bookmarklet/vid2json.png');
            logo.css('float','left');

            close_button = $(document.createElement('img'));
            close_button.attr('src','http://www.cityofdev.com/apps/bookmarklet/close_button.jpg');
            close_button.css('float','right');
            close_button.bind('click',function(){
                $('#vid2json_container').hide(500,function(){ 
                    $(this).remove();
                });
            });

            output = $(document.createElement('div'));
            output.attr('id','vid2json_output');
            output.css('color','#ffffff');

            container.append(logo);
            container.append(close_button);
            container.append(divider_01);
            container.append(output);

            $('body').prepend(container.show(500)); 
        }

        destination = $('#vid2json_output');
        destination.html('');

        items = $('div[itemprop=video]');

        output = $(document.createElement('div'));
        output.css('display','block');
        output.css('padding','0 0 10px');

        if(items.length > 0)
        {
            $.each(items,function(index,el){
                title = $(this).find('*[itemprop=name]').attr('content');
                thumbnail = getThumb($(this).find('*[itemprop=thumbnailUrl]'));
                filename =  getFilename($(this).find('*[itemprop=contentUrl]'));
                filelocation = getFilelocation($(this).find('*[itemprop=contentUrl]'));
                description = $(this).find('*[itemprop=description]').attr('content');
                city = getCity();
                citylink = getCitylink();
                category = getCategory();
                categorylink = getCategorylink();
                duration = $(this).find('*[itemprop=duration]').attr('content');

                head = $(document.createElement('span'));
                head.html(title+' -> JSON<br />\n');
                head.css('display','block');
                head.css('font-weight','700');
                head.css('font-size','12px');

                textarea = $(document.createElement('textarea'));
                textarea.css('width','100%');
                textarea.css('height','300px');
                textarea.css('margin','0 0 20px');

                vCode = '';
                vCode += '      {\n';
                vCode += '          &quot;title&quot;: &quot;'+title+'&quot;,\n';
                vCode += '          &quot;thumbnail&quot;: &quot;'+thumbnail+'&quot;,\n';
                vCode += '          &quot;filename&quot;: &quot;'+filename+'&quot;,\n';
                vCode += '          &quot;filelocation&quot;: &quot;'+filelocation+'&quot;,\n';
                vCode += '          &quot;description&quot;: &quot;'+description+'&quot;,\n';
                vCode += '          &quot;city&quot;: &quot;'+city+'&quot;,\n';
                vCode += '          &quot;citylink&quot;: &quot;'+citylink+'&quot;,\n';
                vCode += '          &quot;category&quot;: &quot;'+category+'&quot;,\n';
                vCode += '          &quot;categorylink&quot;: &quot;'+categorylink+'&quot;,\n';
                vCode += '          &quot;duration&quot;: &quot;'+duration+'&quot;,\n';
                vCode += '          &quot;height&quot;: &quot;&quot;,\n';
                vCode += '          &quot;width&quot;: &quot;&quot;\n';
                vCode += '      }\n';

                textarea.val(vCode);

                output.append(head);
                output.append(textarea);
                destination.append(output);
            });
        }else{
            output.html('No Items Found');
            destination.html(output);
        }

        scrollToTop = $(document.createElement('div'));
        scrollToTop.html('Scroll To Top');
        scrollToTop.css('cursor','pointer');
        scrollToTop.bind('click',function(){
            $('#vid2json_container').animate({ scrollTop: 0 },1000);
        });

        footer = $(document.createElement('div'));
        footer.css('font-size','9px');
        footer.css('color','#555555');
        footer.css('padding','5px 0');
        footer.html('VID2JSON bookmarklet programmed by David A Perez');

        destination.append(scrollToTop);
        destination.append(footer);

    };      

    var checkJquery = function(){
        if(typeof jQuery == 'undefined')
        {
            script01 = document.createElement('SCRIPT');
            script01.src = 'http://code.jquery.com/jquery-1.9.1.min.js';
            script01.type = 'text/javascript';
            document.getElementsByTagName('head')[0].appendChild(script01);
        }else{
            clearTimeout(interval);
            jQueryIsReady();
        }
    };

    var interval = setInterval(checkJquery,100);


    function getCategorylink()
    {
        catl = location.href;
        return catl;
    }

    function getCategory()
    {
        cat = $('.cat-header, .category-header').find('span, h1').html();

        return cat.replace(/^( ){1,}|( ){1,}$/gi,'');
    }

    function getCitylink()
    {
        cl = location.href;
        x = cl.indexOf('/',8);
        return cl.substr(0,x);
    }

    function getCity()
    {
        c = $('title').html();
        x = c.lastIndexOf('-');
        c = c.substr(x+1);
        y = c.lastIndexOf(',');
        c = c.substr(0,y);

        return c.replace(/^( ){1,}|( ){1,}$/gi,'');
    }

    function getFilelocation(gfl)
    {
        if(gfl.is('meta'))
        {
            gflocation = gfl.prop('content');
        }else{
            gflocation = gfl.attr('href');
        }

        x = gflocation.lastIndexOf('/');
        gflocation = gflocation.replace(/www/gi,'ww');
        gflocation = gflocation.substr(0,x+1);
        gflocation = gflocation.replace(/[^\/]{1,}$/,'');
        return gflocation.replace(/[\/]{2,}$/,'\/');
    }

    function getFilename(gfn)
    {
        if(gfn.is('meta'))
        {
            gfname = gfn.prop('content');
        }else{
            gfname = gfn.attr('href');
        }
        x = gfname.lastIndexOf('/');
        gfname = gfname.substr(x+1);
        y = gfname.lastIndexOf('.');
        gfname = gfname.substr(0,y);
        return gfname;
    }

    function getThumb(gt)
    {
        alert(gt.is('meta'));
        if(gt.is('meta'))
        {
            gtname = gt.prop('content');
        }else{
            gtname = gt.attr('src');
        }
        num = gtname.lastIndexOf('/');
        return gtname.substr(num+1);
    }        
})();">vid2json</a>
当itemprops位于meta标记中时,它可以正常工作,但是在

<td class="ad" colspan="2" bgcolor="#000000" style="border:solid #CCCCCC 1px;">
<div itemscope itemtype="http://schema.org/LocalBusiness" style="color:#222222; font-weight: bold; text-align: center; width:580px;">
    <div itemprop="video" itemscope itemtype="http://schema.org/VideoObject">
        <meta itemprop="name" content="P.C.C.S. Dryer Vent Cleaning" />
        <meta itemprop="duration" content="T1M20S" />
        <meta itemprop="description" content="Fort Worth, TX dryer vent cleaning service." />
        <meta itemprop="height" content="580" />
        <meta itemprop="width" content="326" />
        <a href="http://204.145.110.12/thecityoffortworth.com/videos/pccs-dryer-vent-cleaning.mp4" itemprop="contentURL" style="display:block;width:580px; height:326px; border:0px; margin-bottom:104px;" id="pccs">
        <img src="pccs-dryer-vent-cleaning.png" alt="P.C.C.S. Dryer Vent Cleaning" width="580" height="430" border="0" itemprop="thumbnailURL" />
        </a>
    </div>
    <a href="http://www.fortworthsweep.com" class="style5" target="_blank" rel="nofollow" itemprop="url" style="color:#ffffff">www.fortworthsweep.com</a>
</div>

它返回0个项目。我已经尝试了.find('meta[itemprop=contentURL],a[itemprop=contentURL]),但它也返回0个项目。抢劫真的像是一个标签,有什么想法吗


如果我做错了什么,我也向你道歉,这是我第一次在Stackoverflow上发帖,我大部分时间都是自学Javascript和jQuery的。我正在尽我最大的努力去了解什么是可能的,我能做些什么来帮助他们。谢谢你的耐心和帮助

如您在中所见,
.prop('tagName')
的一般概念运行良好。问题更可能是jQuery对象为空(例如,选择器没有找到任何内容)。要查看这是否是您的问题,请检查jQuery对象上的
.length
属性

此外,您没有向我们显示此代码的总体上下文。如果它是在解析页面之前执行的,那么这可能是jQuery对象为空的另一个原因

根据:

它返回未定义的属性值的undefined 集合,或者如果匹配的集合没有元素

由于始终设置标记名属性,更可能的问题是jQuery对象为空


在您提供的链接页面中,我找不到在任何代码中设置断点的方法,因此我甚至不确定是否正在调用/执行它。这似乎是由于您将大量代码放入
javascript:
链接,而不仅仅是调用函数造成的。

jQuery有另一种方法来测试元素是否是特定的标记类型,
.is()
方法:

if (gsn.is("meta"))

不确定为什么
.prop
调用未定义,除非gfn为空。

找到解决方案

它花了很长的时间强制它检查所有内容,选择器和.find()似乎没有得到我想要的结果(可能是因为不一致的大写字母),但我终于成功地让它工作了

<a href="javascript:(function(){
var jQueryIsReady = function(){  
        if($('#vid2json_container').length < 1)
        {
            container = $(document.createElement('div'));
            container.attr('id','vid2json_container');
            container.css('position','fixed');
            container.css('top','0');
            container.css('left','0');
            container.css('background-color','#222222');
            container.css('padding','2px');
            container.css('border-style','solid');
            container.css('border-width','1px');
            container.css('border-color','#000000');
            container.css('opacity','0.95');
            container.css('z-index','999997');
            container.css('width','500px');
            container.css('height',window.innerHeight);
            container.css('overflow-y','auto');
            container.css('overflow-x','hidden');
            container.hide();

            divider_01 = $(document.createElement('div'));
            divider_01.css('clear','both');
            divider_02 = $(document.createElement('div'));
            divider_02.css('clear','both');

            logo = $(document.createElement('img'));
            logo.attr('src','http://www.cityofdev.com/apps/bookmarklet/vid2json.png');
            logo.css('float','left');

            close_button = $(document.createElement('img'));
            close_button.attr('src','http://www.cityofdev.com/apps/bookmarklet/close_button.jpg');
            close_button.css('float','right');
            close_button.bind('click',function(){
                $('#vid2json_container').hide(500,function(){ 
                    $(this).remove();
                });
            });

            nak = $(document.createElement('img'));
            nak.attr('id','naknak');
            nak.attr('src', 'http://www.cityofdev.com/apps/bookmarklet/naknak.gif');
            nak.css('float','left');
            nak.css('width','143px');
            nak.css('height','119px');
            nak.css('z-index','99998');

            salamander = $(document.createElement('img'));
            salamander.attr('id','salamander');
            salamander.attr('src', 'http://www.cityofdev.com/apps/bookmarklet/salamander.gif');
            salamander.css('float','right');
            salamander.css('width','112px');
            salamander.css('height','117px');
            salamander.css('z-index','99998');

            output = $(document.createElement('div'));
            output.attr('id','vid2json_output');
            output.css('color','#ffffff');

            container.append(logo);
            container.append(close_button);
            container.append(divider_01);
            container.append(nak);
            container.append(salamander);
            container.append(divider_02);
            container.append(output);

            $('body').prepend(container.show(500)); 
        }

        destination = $('#vid2json_output');
        destination.html('');

        items = $('div[itemprop=video]');

        output = $(document.createElement('div'));
        output.css('display','block');
        output.css('padding','0 0 10px');

        if(items.length > 0)
        {
            $.each(items,function(index,el){
                children = $(el).find('*');
                $.each(children, function(i,ele){
                    n = $(ele);
                    if(n.attr('itemprop') !== undefined)
                    {
                        switch(n.attr('itemprop').toLowerCase())
                        {
                            case 'name':
                                title = n.attr('content');
                            break;

                            case 'contenturl':
                                filename = getFilename(n);
                                filelocation = getFilelocation(n);
                            break;

                            case 'thumbnailurl':
                                thumbnail = getThumb(n);
                            break;

                            case 'description':
                                description = n.attr('content');
                            break;

                            case 'duration':
                                duration = n.attr('content');
                            break;
                            default:
                            break;
                        }                        
                    }

                });
                city = getCity();
                citylink = getCitylink();
                category = getCategory();
                categorylink = getCategorylink();

                head = $(document.createElement('span'));
                head.html(title+' -> JSON<br />\n');
                head.css('display','block');
                head.css('font-weight','700');
                head.css('font-size','12px');

                textarea = $(document.createElement('textarea'));
                textarea.css('width','100%');
                textarea.css('height','300px');
                textarea.css('margin','0 0 20px');

                vCode = '';
                vCode += '      {\n';
                vCode += '          &quot;title&quot;: &quot;'+title+'&quot;,\n';
                vCode += '          &quot;thumbnail&quot;: &quot;'+thumbnail+'&quot;,\n';
                vCode += '          &quot;filename&quot;: &quot;'+filename+'&quot;,\n';
                vCode += '          &quot;filelocation&quot;: &quot;'+filelocation+'&quot;,\n';
                vCode += '          &quot;description&quot;: &quot;'+description+'&quot;,\n';
                vCode += '          &quot;city&quot;: &quot;'+city+'&quot;,\n';
                vCode += '          &quot;citylink&quot;: &quot;'+citylink+'&quot;,\n';
                vCode += '          &quot;category&quot;: &quot;'+category+'&quot;,\n';
                vCode += '          &quot;categorylink&quot;: &quot;'+categorylink+'&quot;,\n';
                vCode += '          &quot;duration&quot;: &quot;'+duration+'&quot;,\n';
                vCode += '          &quot;height&quot;: &quot;&quot;,\n';
                vCode += '          &quot;width&quot;: &quot;&quot;\n';
                vCode += '      }\n';

                textarea.val(vCode);

                output.append(head);
                output.append(textarea);
                destination.append(output);
            });
        }else{
            output.html('No Items Found');
            destination.html(output);
        }

        scrollToTop = $(document.createElement('div'));
        scrollToTop.html('Scroll To Top');
        scrollToTop.css('cursor','pointer');
        scrollToTop.bind('click',function(){
            $('#vid2json_container').animate({ scrollTop: 0 },1000);
        });

        footer = $(document.createElement('div'));
        footer.css('font-size','9px');
        footer.css('color','#555555');
        footer.css('padding','5px 0');
        footer.html('VID2JSON bookmarklet programmed by David A Perez');

        destination.append(scrollToTop);
        destination.append(footer);

    };      

    var checkJquery = function(){
        if(typeof jQuery == 'undefined')
        {
            script01 = document.createElement('SCRIPT');
            script01.src = 'http://code.jquery.com/jquery-1.9.1.min.js';
            script01.type = 'text/javascript';
            document.getElementsByTagName('head')[0].appendChild(script01);
        }else{
            clearTimeout(interval);
            jQueryIsReady();
        }
    };

    var interval = setInterval(checkJquery,100);


    function getCategorylink()
    {
        catl = location.href;
        return catl;
    }

    function getCategory()
    {
        cat = $('.cat-header, .category-header').find('span, h1').html();

        return cat.replace(/^( ){1,}|( ){1,}$/gi,'');
    }

    function getCitylink()
    {
        cl = location.href;
        x = cl.indexOf('/',8);
        return cl.substr(0,x);
    }

    function getCity()
    {
        c = $('title').html();
        x = c.lastIndexOf('-');
        c = c.substr(x+1);
        y = c.lastIndexOf(',');
        c = c.substr(0,y);

        return c.replace(/^( ){1,}|( ){1,}$/gi,'');
    }

    function getFilelocation(gfl)
    {
        if(gfl.length<1){return 'contentURL not found'+gfl.length;}
        if(gfl.is('meta'))
        {
            gflocation = gfl.prop('content');
        }else{
            gflocation = gfl.attr('href');
        }

        x = gflocation.lastIndexOf('/');
        gflocation = gflocation.replace(/www/gi,'ww');
        gflocation = gflocation.substr(0,x+1);
        gflocation = gflocation.replace(/[^\/]{1,}$/,'');
        return gflocation.replace(/[\/]{2,}$/,'\/');
    }

    function getFilename(gfn)
    {
        if(gfn.length<1){return 'contentURL not found'+gfn.length;}
        if(gfn.is('meta'))
        {
            gfname = gfn.prop('content');
        }else{
            gfname = gfn.attr('href');
        }
        x = gfname.lastIndexOf('/');
        gfname = gfname.substr(x+1);
        y = gfname.lastIndexOf('.');
        gfname = gfname.substr(0,y);
        return gfname;
    }

    function getThumb(gt)
    {
        if(gt.length<1){return 'thumbnailURL not found'+gt.length;}
        if(gt.is('meta'))
        {
            gtname = gt.prop('content');
        }else{
            gtname = gt.attr('src');
        }
        num = gtname.lastIndexOf('/');
        return gtname.substr(num+1);
    }        
})();">vid2json</a>

也许有更有效的方法来解决这个问题,但它似乎足够可靠地完成这项工作。在遇到情况时,我可能会补充更多内容。谢谢大家的建议,它帮助我找到了这个解决方案

我没有把整件事都放到我的帖子里,因为我担心这会是一个太大的文本转储,这就是为什么如果有人想看完整的东西,我会提供它们的原因,对此表示抱歉。它应该作为一个bookmarklet运行,我相信我已经提到过,目的是让它可以在我们需要的时候在网站上的任何页面上运行。在开始处理之前,它会检查jQuery,如果找不到则加载它。它似乎运行/处理良好,直到它尝试使用itemprop查找项目,如果它们不在meta标记中,它不会返回任何内容是的,gfn如果无法在meta标记中找到它要查找的itemprop,它似乎会返回0结果,我希望找到正确的选择器,它可以在匹配的div中找到itemprop,而不管它在哪个标签中,但我自己却没有找到它。is('meta')可以工作,并且应该有助于检查元素是否是meta标记。谢谢你的帮助!已将.find()更改为.children(),因为itemprop thumbnailURL位于的内部,但现在似乎找不到。find()将找到
,因为它是
的后代,但
.children()
不会,因为它只扫描直接子代,而不是所有子代。
<a href="javascript:(function(){
var jQueryIsReady = function(){  
        if($('#vid2json_container').length < 1)
        {
            container = $(document.createElement('div'));
            container.attr('id','vid2json_container');
            container.css('position','fixed');
            container.css('top','0');
            container.css('left','0');
            container.css('background-color','#222222');
            container.css('padding','2px');
            container.css('border-style','solid');
            container.css('border-width','1px');
            container.css('border-color','#000000');
            container.css('opacity','0.95');
            container.css('z-index','999997');
            container.css('width','500px');
            container.css('height',window.innerHeight);
            container.css('overflow-y','auto');
            container.css('overflow-x','hidden');
            container.hide();

            divider_01 = $(document.createElement('div'));
            divider_01.css('clear','both');
            divider_02 = $(document.createElement('div'));
            divider_02.css('clear','both');

            logo = $(document.createElement('img'));
            logo.attr('src','http://www.cityofdev.com/apps/bookmarklet/vid2json.png');
            logo.css('float','left');

            close_button = $(document.createElement('img'));
            close_button.attr('src','http://www.cityofdev.com/apps/bookmarklet/close_button.jpg');
            close_button.css('float','right');
            close_button.bind('click',function(){
                $('#vid2json_container').hide(500,function(){ 
                    $(this).remove();
                });
            });

            nak = $(document.createElement('img'));
            nak.attr('id','naknak');
            nak.attr('src', 'http://www.cityofdev.com/apps/bookmarklet/naknak.gif');
            nak.css('float','left');
            nak.css('width','143px');
            nak.css('height','119px');
            nak.css('z-index','99998');

            salamander = $(document.createElement('img'));
            salamander.attr('id','salamander');
            salamander.attr('src', 'http://www.cityofdev.com/apps/bookmarklet/salamander.gif');
            salamander.css('float','right');
            salamander.css('width','112px');
            salamander.css('height','117px');
            salamander.css('z-index','99998');

            output = $(document.createElement('div'));
            output.attr('id','vid2json_output');
            output.css('color','#ffffff');

            container.append(logo);
            container.append(close_button);
            container.append(divider_01);
            container.append(nak);
            container.append(salamander);
            container.append(divider_02);
            container.append(output);

            $('body').prepend(container.show(500)); 
        }

        destination = $('#vid2json_output');
        destination.html('');

        items = $('div[itemprop=video]');

        output = $(document.createElement('div'));
        output.css('display','block');
        output.css('padding','0 0 10px');

        if(items.length > 0)
        {
            $.each(items,function(index,el){
                children = $(el).find('*');
                $.each(children, function(i,ele){
                    n = $(ele);
                    if(n.attr('itemprop') !== undefined)
                    {
                        switch(n.attr('itemprop').toLowerCase())
                        {
                            case 'name':
                                title = n.attr('content');
                            break;

                            case 'contenturl':
                                filename = getFilename(n);
                                filelocation = getFilelocation(n);
                            break;

                            case 'thumbnailurl':
                                thumbnail = getThumb(n);
                            break;

                            case 'description':
                                description = n.attr('content');
                            break;

                            case 'duration':
                                duration = n.attr('content');
                            break;
                            default:
                            break;
                        }                        
                    }

                });
                city = getCity();
                citylink = getCitylink();
                category = getCategory();
                categorylink = getCategorylink();

                head = $(document.createElement('span'));
                head.html(title+' -> JSON<br />\n');
                head.css('display','block');
                head.css('font-weight','700');
                head.css('font-size','12px');

                textarea = $(document.createElement('textarea'));
                textarea.css('width','100%');
                textarea.css('height','300px');
                textarea.css('margin','0 0 20px');

                vCode = '';
                vCode += '      {\n';
                vCode += '          &quot;title&quot;: &quot;'+title+'&quot;,\n';
                vCode += '          &quot;thumbnail&quot;: &quot;'+thumbnail+'&quot;,\n';
                vCode += '          &quot;filename&quot;: &quot;'+filename+'&quot;,\n';
                vCode += '          &quot;filelocation&quot;: &quot;'+filelocation+'&quot;,\n';
                vCode += '          &quot;description&quot;: &quot;'+description+'&quot;,\n';
                vCode += '          &quot;city&quot;: &quot;'+city+'&quot;,\n';
                vCode += '          &quot;citylink&quot;: &quot;'+citylink+'&quot;,\n';
                vCode += '          &quot;category&quot;: &quot;'+category+'&quot;,\n';
                vCode += '          &quot;categorylink&quot;: &quot;'+categorylink+'&quot;,\n';
                vCode += '          &quot;duration&quot;: &quot;'+duration+'&quot;,\n';
                vCode += '          &quot;height&quot;: &quot;&quot;,\n';
                vCode += '          &quot;width&quot;: &quot;&quot;\n';
                vCode += '      }\n';

                textarea.val(vCode);

                output.append(head);
                output.append(textarea);
                destination.append(output);
            });
        }else{
            output.html('No Items Found');
            destination.html(output);
        }

        scrollToTop = $(document.createElement('div'));
        scrollToTop.html('Scroll To Top');
        scrollToTop.css('cursor','pointer');
        scrollToTop.bind('click',function(){
            $('#vid2json_container').animate({ scrollTop: 0 },1000);
        });

        footer = $(document.createElement('div'));
        footer.css('font-size','9px');
        footer.css('color','#555555');
        footer.css('padding','5px 0');
        footer.html('VID2JSON bookmarklet programmed by David A Perez');

        destination.append(scrollToTop);
        destination.append(footer);

    };      

    var checkJquery = function(){
        if(typeof jQuery == 'undefined')
        {
            script01 = document.createElement('SCRIPT');
            script01.src = 'http://code.jquery.com/jquery-1.9.1.min.js';
            script01.type = 'text/javascript';
            document.getElementsByTagName('head')[0].appendChild(script01);
        }else{
            clearTimeout(interval);
            jQueryIsReady();
        }
    };

    var interval = setInterval(checkJquery,100);


    function getCategorylink()
    {
        catl = location.href;
        return catl;
    }

    function getCategory()
    {
        cat = $('.cat-header, .category-header').find('span, h1').html();

        return cat.replace(/^( ){1,}|( ){1,}$/gi,'');
    }

    function getCitylink()
    {
        cl = location.href;
        x = cl.indexOf('/',8);
        return cl.substr(0,x);
    }

    function getCity()
    {
        c = $('title').html();
        x = c.lastIndexOf('-');
        c = c.substr(x+1);
        y = c.lastIndexOf(',');
        c = c.substr(0,y);

        return c.replace(/^( ){1,}|( ){1,}$/gi,'');
    }

    function getFilelocation(gfl)
    {
        if(gfl.length<1){return 'contentURL not found'+gfl.length;}
        if(gfl.is('meta'))
        {
            gflocation = gfl.prop('content');
        }else{
            gflocation = gfl.attr('href');
        }

        x = gflocation.lastIndexOf('/');
        gflocation = gflocation.replace(/www/gi,'ww');
        gflocation = gflocation.substr(0,x+1);
        gflocation = gflocation.replace(/[^\/]{1,}$/,'');
        return gflocation.replace(/[\/]{2,}$/,'\/');
    }

    function getFilename(gfn)
    {
        if(gfn.length<1){return 'contentURL not found'+gfn.length;}
        if(gfn.is('meta'))
        {
            gfname = gfn.prop('content');
        }else{
            gfname = gfn.attr('href');
        }
        x = gfname.lastIndexOf('/');
        gfname = gfname.substr(x+1);
        y = gfname.lastIndexOf('.');
        gfname = gfname.substr(0,y);
        return gfname;
    }

    function getThumb(gt)
    {
        if(gt.length<1){return 'thumbnailURL not found'+gt.length;}
        if(gt.is('meta'))
        {
            gtname = gt.prop('content');
        }else{
            gtname = gt.attr('src');
        }
        num = gtname.lastIndexOf('/');
        return gtname.substr(num+1);
    }        
})();">vid2json</a>
$.each(children, function(i,ele){
                    n = $(ele);
                    if(n.attr('itemprop') !== undefined)
                    {
                        switch(n.attr('itemprop').toLowerCase())
                        {
                            case 'name':
                                title = n.attr('content');
                            break;

                            case 'contenturl':
                                filename = getFilename(n);
                                filelocation = getFilelocation(n);
                            break;

                            case 'thumbnailurl':
                                thumbnail = getThumb(n);
                            break;

                            case 'description':
                                description = n.attr('content');
                            break;

                            case 'duration':
                                duration = n.attr('content');
                            break;
                            default:
                            break;
                        }                        
                    }
});