How to use the css-select function in css-select

To help you get started, we’ve selected a few css-select examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aMarcireau / origami / source / actions / manageScholar.js View on Github external
numberOfCiters: 0,
                                    scholarId: null,
                                }, refractoryPeriod);
                                break;
                            case SCHOLAR_REQUEST_TYPE_CITERS:
                                dispatchAndEcho({type: RESOLVE_SCHOLAR_CITERS_REQUEST}, refractoryPeriod);
                                break;
                            default:
                                console.error(`Unexpected Scholar request type ${state.scholar.requests[0].type}`);
                                dispatchAndEcho(null, refractoryPeriod);
                                break;
                        }
                    } else {
                        switch (state.scholar.requests[0].type) {
                            case SCHOLAR_REQUEST_TYPE_INITIALIZE: {
                                const publications = cssSelect(publicationsQuery, dom);
                                const candidates = [];
                                for (const publication of publications) {
                                    const titleCandidates = cssSelect(titleFromPublicationQuery, publication);
                                    if (
                                        titleCandidates.length === 0
                                        || !titleCandidates[0].children
                                        || titleCandidates[0].children.length === 0
                                        || titleCandidates[0].children[0].type !== 'text'
                                    ) {
                                        continue;
                                    }
                                    for (let citersLinkCandidate of cssSelect(citersLinkFromPublicationQuery, publication)) {
                                        if (
                                            citersLinkCandidate.children
                                            && citersLinkCandidate.children.length > 0
                                            && citersLinkCandidate.children[0].type === 'text'
github aMarcireau / origami / source / actions / manageScholar.js View on Github external
break;
                            case SCHOLAR_REQUEST_TYPE_CITERS:
                                dispatchAndEcho({type: RESOLVE_SCHOLAR_CITERS_REQUEST}, refractoryPeriod);
                                break;
                            default:
                                console.error(`Unexpected Scholar request type ${state.scholar.requests[0].type}`);
                                dispatchAndEcho(null, refractoryPeriod);
                                break;
                        }
                    } else {
                        switch (state.scholar.requests[0].type) {
                            case SCHOLAR_REQUEST_TYPE_INITIALIZE: {
                                const publications = cssSelect(publicationsQuery, dom);
                                const candidates = [];
                                for (const publication of publications) {
                                    const titleCandidates = cssSelect(titleFromPublicationQuery, publication);
                                    if (
                                        titleCandidates.length === 0
                                        || !titleCandidates[0].children
                                        || titleCandidates[0].children.length === 0
                                        || titleCandidates[0].children[0].type !== 'text'
                                    ) {
                                        continue;
                                    }
                                    for (let citersLinkCandidate of cssSelect(citersLinkFromPublicationQuery, publication)) {
                                        if (
                                            citersLinkCandidate.children
                                            && citersLinkCandidate.children.length > 0
                                            && citersLinkCandidate.children[0].type === 'text'
                                            && citersLinkCandidate.attribs
                                            && citersLinkCandidate.attribs.href
                                        ) {
github aMarcireau / origami / source / actions / manageScholar.js View on Github external
...candidate,
                                                distance,
                                            };
                                        }
                                        return best;
                                    }, null);
                                    dispatchAndEcho({
                                        type: RESOLVE_SCHOLAR_INITIAL_REQUEST,
                                        numberOfCiters: bestCandidate.numberOfCiters,
                                        scholarId: bestCandidate.scholarId,
                                    }, refractoryPeriod);
                                }
                                break;
                            }
                            case SCHOLAR_REQUEST_TYPE_CITERS: {
                                const publications = cssSelect(publicationsQuery, dom);
                                if (publications.length > 0) {
                                    for (const publication of publications) {
                                        const titleCandidates = cssSelect(titleFromPublicationQuery, publication);
                                        if (
                                            titleCandidates.length === 0
                                            || !titleCandidates[0].children
                                            || titleCandidates[0].children.length === 0
                                            || titleCandidates[0].children[0].type !== 'text'
                                        ) {
                                            dispatch({
                                                type: REJECT_SCHOLAR_CITER_PARSING,
                                                doi: state.scholar.requests[0].doi,
                                                title: `Parsing a citer's metadata for ${state.scholar.requests[0].doi} failed`,
                                                subtitle: 'Tags with the class \'gs_rt\' and link children could not be found',
                                            });
                                            continue;
github aMarcireau / origami / source / actions / manageScholar.js View on Github external
const state = getState();
                const blocked = state.scholar.status === SCHOLAR_STATUS_BLOCKED_HIDDEN || state.scholar.status === SCHOLAR_STATUS_BLOCKED_VISIBLE;
                if (
                    cssSelect(firstCategoryRecaptchaQuery, dom).length > 0
                    || cssSelect(secondCategoryRecaptchaQuery, dom).length > 0
                ) {
                    if (!blocked) {
                        dispatch({
                            type: BLOCK_SCHOLAR,
                            url,
                        });
                    }
                } else if (
                    decodeURIComponent(url) === 'https://ipv4.google.com/sorry/index'
                    || (cssSelect(titleQuery, dom).length > 0
                        && cssSelect(titleQuery, dom)[0].children
                        && cssSelect(titleQuery, dom)[0].children[0].data === 'Sorry...'
                    )
                ) {
                    ipcRenderer.once('cookies-cleared', () => {
                        dispatchAndEcho({type: RESET_SCHOLAR}, 0);
                    });
                    ipcRenderer.send('clear-cookies');
                } else {
                    const refractoryPeriod = Math.floor(
                        Math.random() * (1 + state.scholar.maximumRefractoryPeriod - state.scholar.minimumRefractoryPeriod)
                    ) + state.scholar.minimumRefractoryPeriod;
                    if (!state.publications.has(state.scholar.requests[0].doi)) {
                        switch (state.scholar.requests[0].type) {
                            case SCHOLAR_REQUEST_TYPE_INITIALIZE:
                                dispatchAndEcho({
                                    type: RESOLVE_SCHOLAR_INITIAL_REQUEST,
github aMarcireau / origami / source / actions / manageScholar.js View on Github external
.then(dom => {
                const state = getState();
                const blocked = state.scholar.status === SCHOLAR_STATUS_BLOCKED_HIDDEN || state.scholar.status === SCHOLAR_STATUS_BLOCKED_VISIBLE;
                if (
                    cssSelect(firstCategoryRecaptchaQuery, dom).length > 0
                    || cssSelect(secondCategoryRecaptchaQuery, dom).length > 0
                ) {
                    if (!blocked) {
                        dispatch({
                            type: BLOCK_SCHOLAR,
                            url,
                        });
                    }
                } else if (
                    decodeURIComponent(url) === 'https://ipv4.google.com/sorry/index'
                    || (cssSelect(titleQuery, dom).length > 0
                        && cssSelect(titleQuery, dom)[0].children
                        && cssSelect(titleQuery, dom)[0].children[0].data === 'Sorry...'
                    )
                ) {
                    ipcRenderer.once('cookies-cleared', () => {
github aMarcireau / origami / source / actions / manageScholar.js View on Github external
.then(dom => {
                const state = getState();
                const blocked = state.scholar.status === SCHOLAR_STATUS_BLOCKED_HIDDEN || state.scholar.status === SCHOLAR_STATUS_BLOCKED_VISIBLE;
                if (
                    cssSelect(firstCategoryRecaptchaQuery, dom).length > 0
                    || cssSelect(secondCategoryRecaptchaQuery, dom).length > 0
                ) {
                    if (!blocked) {
                        dispatch({
                            type: BLOCK_SCHOLAR,
                            url,
                        });
                    }
                } else if (
                    decodeURIComponent(url) === 'https://ipv4.google.com/sorry/index'
                    || (cssSelect(titleQuery, dom).length > 0
                        && cssSelect(titleQuery, dom)[0].children
                        && cssSelect(titleQuery, dom)[0].children[0].data === 'Sorry...'
                    )
                ) {
                    ipcRenderer.once('cookies-cleared', () => {
                        dispatchAndEcho({type: RESET_SCHOLAR}, 0);
                    });
                    ipcRenderer.send('clear-cookies');
                } else {
                    const refractoryPeriod = Math.floor(
                        Math.random() * (1 + state.scholar.maximumRefractoryPeriod - state.scholar.minimumRefractoryPeriod)
                    ) + state.scholar.minimumRefractoryPeriod;
                    if (!state.publications.has(state.scholar.requests[0].doi)) {
                        switch (state.scholar.requests[0].type) {
                            case SCHOLAR_REQUEST_TYPE_INITIALIZE:
                                dispatchAndEcho({
github aMarcireau / origami / source / actions / manageScholar.js View on Github external
.then(dom => {
                const state = getState();
                const blocked = state.scholar.status === SCHOLAR_STATUS_BLOCKED_HIDDEN || state.scholar.status === SCHOLAR_STATUS_BLOCKED_VISIBLE;
                if (
                    cssSelect(firstCategoryRecaptchaQuery, dom).length > 0
                    || cssSelect(secondCategoryRecaptchaQuery, dom).length > 0
                ) {
                    if (!blocked) {
                        dispatch({
                            type: BLOCK_SCHOLAR,
                            url,
                        });
                    }
                } else if (
                    decodeURIComponent(url) === 'https://ipv4.google.com/sorry/index'
                    || (cssSelect(titleQuery, dom).length > 0
                        && cssSelect(titleQuery, dom)[0].children
                        && cssSelect(titleQuery, dom)[0].children[0].data === 'Sorry...'
                    )
                ) {
                    ipcRenderer.once('cookies-cleared', () => {
                        dispatchAndEcho({type: RESET_SCHOLAR}, 0);
github react-native-community / react-native-svg / src / css.tsx View on Github external
function querySelectorAll(query: Query, elems: XmlAST | XmlAST[]): XmlAST[] {
  return cssSelect(query, elems, cssSelectOpts);
}
github aMarcireau / origami / source / actions / manageScholar.js View on Github external
const titleCandidates = cssSelect(titleFromPublicationQuery, publication);
                                        if (
                                            titleCandidates.length === 0
                                            || !titleCandidates[0].children
                                            || titleCandidates[0].children.length === 0
                                            || titleCandidates[0].children[0].type !== 'text'
                                        ) {
                                            dispatch({
                                                type: REJECT_SCHOLAR_CITER_PARSING,
                                                doi: state.scholar.requests[0].doi,
                                                title: `Parsing a citer's metadata for ${state.scholar.requests[0].doi} failed`,
                                                subtitle: 'Tags with the class \'gs_rt\' and link children could not be found',
                                            });
                                            continue;
                                        }
                                        const metadataCandidates = cssSelect(metadataFromPublicationQuery, publication);
                                        if (
                                            metadataCandidates.length === 0
                                            || !metadataCandidates[0].children
                                        ) {
                                            dispatch({
                                                type: REJECT_SCHOLAR_CITER_PARSING,
                                                doi: state.scholar.requests[0].doi,
                                                title: `Parsing a citer's metadata for ${state.scholar.requests[0].doi} failed`,
                                                subtitle: 'Tags with the class \'gs_a\' could not be found',
                                            });
                                            continue;
                                        }
                                        let metadata = '';
                                        for (let child of metadataCandidates[0].children) {
                                            if (child.type === 'text') {
                                                metadata += child.data.replace(/ /g, ' ');

css-select

a CSS selector compiler/engine

BSD-2-Clause
Latest version published 2 years ago

Package Health Score

82 / 100
Full package analysis