Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Scholar [patch] #432

Closed
fbennett opened this issue Jul 21, 2012 · 0 comments
Closed

Google Scholar [patch] #432

fbennett opened this issue Jul 21, 2012 · 0 comments

Comments

@fbennett
Copy link
Contributor

This is a patch that will get Google Scholar working again. Apologies for submitting in this form: I need to shift my MLZ translator repo to a branch, but I've been putting off the work because it will impact the MLZ update chain, and I don't currently have time for the debugging.

Anyway, here is the patch.

Cheers,
Frank

--- Google Scholar.js   2012-07-21 20:48:38.525122854 +0900
+++ /home/bennett/.mozilla/firefox/vdzbh5n4.3.0.8/zotero/translators/Google Scholar.js  2012-07-21 21:06:31.429131733 +0900
@@ -46,7 +46,7 @@
        url.indexOf('about=') == -1) {
            return "case";
    } else if( ZU.xpath(doc,
-       '//div[@class="gs_r"]/div[@class="gs_fl"]/a[contains(@href,"q=related:")]')
+       '//div[@class="gs_r"]//div[@class="gs_fl"]/a[contains(@href,"q=related:")]')
        .length ) {
        return "multiple";
    }
@@ -236,7 +236,7 @@

                        //attach files linked on the right
                        var pdf = ZU.xpath(article.result,
-                           './div[contains(@class,"gs_fl")]\
+                           './/div[contains(@class,"gs_fl")]\
                            /a[./node()[starts-with(text(),"[")]]');
                        for(var i=0, n=pdf.length; i<n; i++) {
                            var attach = getAttachment(pdf[i].href,
@@ -449,18 +449,18 @@
         */
        var results = ZU.xpath(doc,
            '//div[@class="gs_r"]\
-               [./div[@class="gs_fl"]/a[contains(@href,"q=info:") or contains(@href,"q=related:")]]');
+               [.//div[@class="gs_fl"]/a[contains(@href,"q=info:") or contains(@href,"q=related:")]]');

        var items = new Object();
        var resultDivs = new Object();
        var bibtexUrl;
        for(var i=0, n=results.length; i<n; i++) {
            bibtexUrl = ZU.xpathText(results[i],
-               './div[@class="gs_fl"]/a[contains(@href,"q=info:") or contains(@href,"q=related:")][1]/@href')
+               './/div[@class="gs_fl"]/a[contains(@href,"q=info:") or contains(@href,"q=related:")][1]/@href')
                .replace(/\/scholar.*?\?/,'/scholar.bib?')
                .replace(/=related:/,'=info:')
                + '&ct=citation&cd=1&output=citation';
-           items[bibtexUrl] = ZU.xpathText(results[i], './h3[@class="gs_rt"]');
+           items[bibtexUrl] = ZU.xpathText(results[i], './/h3[@class="gs_rt"]');

            //keep the result div for extra information
            resultDivs[bibtexUrl] = results[i];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants