Grepper code extension not showing suggestions and add answer option

1.8k Views Asked by At

As i cleaned up my computer and reinstalled chrome latest version and when i tried using grepper code extension it was not working. It was not showing any answers and not even letting me add a new answer. I tried researching for a while but couldn't find a solution to it.

Then i tried opening it inside the firefox and it was working perfectly and i can even see suggestions and even add new answers.

Then When i checked inside my console log i found some errors while doing a google search and the errors were related to the grepper cross origin issue. I am attaching the screenshot of the issue that occurred

enter image description here

2

There are 2 best solutions below

2
On BEST ANSWER

I solved this error by allowing the cross origin access using the following extension :

https://chrome.google.com/webstore/detail/allow-cors-access-control/lhobafahddgcelffkeicbaginigeejlf?hl=en

and then just reloading the page the errors were gone and you can also check if it is working or not inside the test panel of the extension :

https://webbrowsertools.com/test-cors/

I am attaching some screenshots that will define my solution.

enter image description here

enter image description here

enter image description here

enter image description here

1
On

/* @api */ define([ 'jquery', 'mageUtils' ], function ($, utils) { 'use strict';

var types = [
    {
        title: 'Visa',
        type: 'VI',
        pattern: '^4\\d*$',
        gaps: [4, 8, 12],
        lengths: [16],
        code: {
            name: 'CVV',
            size: 3
        }
    },
    {
        title: 'MasterCard',
        type: 'MC',
        pattern: '^(?:5[1-5][0-9]{2}|222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}$',
        gaps: [4, 8, 12],
        lengths: [16],
        code: {
            name: 'CVC',
            size: 3
        }
    },
    {
        title: 'American Express',
        type: 'AE',
        pattern: '^3([47]\\d*)?$',
        isAmex: true,
        gaps: [4, 10],
        lengths: [15],
        code: {
            name: 'CID',
            size: 4
        }
    },
    {
        title: 'Diners',
        type: 'DN',
        pattern: '^(3(0[0-5]|095|6|[8-9]))\\d*$',
        gaps: [4, 10],
        lengths: [14, 16, 17, 18, 19],
        code: {
            name: 'CVV',
            size: 3
        }
    },
    {
        title: 'Discover',
        type: 'DI',
        pattern: '^(6011(0|[2-4]|74|7[7-9]|8[6-9]|9)|6(4[4-9]|5))\\d*$',
        gaps: [4, 8, 12],
        lengths: [16, 17, 18, 19],
        code: {
            name: 'CID',
            size: 3
        }
    },
    {
        title: 'JCB',
        type: 'JCB',
        pattern: '^35(2[8-9]|[3-8])\\d*$',
        gaps: [4, 8, 12],
        lengths: [16, 17, 18, 19],
        code: {
            name: 'CVV',
            size: 3
        }
    },
    {
        title: 'UnionPay',
        type: 'UN',
        pattern: '^(622(1(2[6-9]|[3-9])|[3-8]|9([[0-1]|2[0-5]))|62[4-6]|628([2-8]))\\d*?$',
        gaps: [4, 8, 12],
        lengths: [16, 17, 18, 19],
        code: {
            name: 'CVN',
            size: 3
        }
    },
    {
        title: 'Maestro International',
        type: 'MI',
        pattern: '^(5(0|[6-9])|63|67(?!59|6770|6774))\\d*$',
        gaps: [4, 8, 12],
        lengths: [12, 13, 14, 15, 16, 17, 18, 19],
        code: {
            name: 'CVC',
            size: 3
        }
    },
    {
        title: 'Maestro Domestic',
        type: 'MD',
        pattern: '^6759(?!24|38|40|6[3-9]|70|76)|676770|676774\\d*$',
        gaps: [4, 8, 12],
        lengths: [12, 13, 14, 15, 16, 17, 18, 19],
        code: {
            name: 'CVC',
            size: 3
        }
    },
    {
        title: 'Hipercard',
        type: 'HC',
        pattern: '^((606282)|(637095)|(637568)|(637599)|(637609)|(637612))\\d*$',
        gaps: [4, 8, 12],
        lengths: [13, 16],
        code: {
            name: 'CVC',
            size: 3
        }
    },
    {
        title: 'Elo',
        type: 'ELO',
        pattern: '^((509091)|(636368)|(636297)|(504175)|(438935)|(40117[8-9])|(45763[1-2])|' +
            '(457393)|(431274)|(50990[0-2])|(5099[7-9][0-9])|(50996[4-9])|(509[1-8][0-9][0-9])|' +
            '(5090(0[0-2]|0[4-9]|1[2-9]|[24589][0-9]|3[1-9]|6[0-46-9]|7[0-24-9]))|' +
            '(5067(0[0-24-8]|1[0-24-9]|2[014-9]|3[0-379]|4[0-9]|5[0-3]|6[0-5]|7[0-8]))|' +
            '(6504(0[5-9]|1[0-9]|2[0-9]|3[0-9]))|' +
            '(6504(8[5-9]|9[0-9])|6505(0[0-9]|1[0-9]|2[0-9]|3[0-8]))|' +
            '(6505(4[1-9]|5[0-9]|6[0-9]|7[0-9]|8[0-9]|9[0-8]))|' +
            '(6507(0[0-9]|1[0-8]))|(65072[0-7])|(6509(0[1-9]|1[0-9]|20))|' +
            '(6516(5[2-9]|6[0-9]|7[0-9]))|(6550(0[0-9]|1[0-9]))|' +
            '(6550(2[1-9]|3[0-9]|4[0-9]|5[0-8])))\\d*$',
        gaps: [4, 8, 12],
        lengths: [16],
        code: {
            name: 'CVC',
            size: 3
        }
    },
    {
        title: 'Aura',
        type: 'AU',
        pattern: '^5078\\d*$',
        gaps: [4, 8, 12],
        lengths: [19],
        code: {
            name: 'CVC',
            size: 3
        }
    }
];

return {
    /**
     * @param {*} cardNumber
     * @return {Array}
     */
    getCardTypes: function (cardNumber) {
        var i, value,
            result = [];

        if (utils.isEmpty(cardNumber)) {
            return result;
        }

        if (cardNumber === '') {
            return $.extend(true, {}, types);
        }

        for (i = 0; i < types.length; i++) {
            value = types[i];