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

Diigo #45

Closed
olegp opened this issue May 14, 2014 · 4 comments
Closed

Diigo #45

olegp opened this issue May 14, 2014 · 4 comments

Comments

@olegp
Copy link
Contributor

olegp commented May 14, 2014

No description provided.

@ilbambino
Copy link

Here it is my fast approach for Diigo:

{
  search: [
    {
      type:'link',
      query:'https://www.diigo.com/search?adSScope=my&what={{term}}&snapshot=no',
      translate:'parseHTML(response)',
      name:{
        selector:'Titleinner',
        expression:'element.getElementsBySelector('a')[0].textContent'
      },
      link:{
        selector:'Titleinner',
        expression:'element.getElementsBySelector('a')[0].getAttribute("href")'
      },
      description:{
        selector:'.description',
        expression:'element.getElementsBySelector('a')[0].textContent'
      }
    }
  ]
}

But so far it doesn't work. When I try to search using it I get the following error:
screen shot 2014-07-15 at 20 55 56

As it is expected the request is not even sent to the diigo servers. (Doesn't show in the Dev console as a request done).

So it is not fully tested, as I cannot really test it. But the selectors work, and the expression also. And the documentation doesn't explicitly say it, but I guess that when the expression is run, the element matched by the selector is named 'element'.

Diigo has a complex DOM, lots of nested divs, and what makes it even more 'complex' is that the classes of the links are like 'title_#' being the # the number of the link returned in the page. (Not only with title but more classes like that are used). And that's the reason to use that kind of expression to navigate through the items. Not very robust but should work once the other issue is solved.

One last thing, the descritption is the same as name. I don't know if the description is optional (nothing in the docs about it) and I have never use the extension before, so I cannot really say if in other apps there is a difference.

@olegp
Copy link
Contributor Author

olegp commented Jul 15, 2014

You can ignore the error, it's not caused by the code running your provider.

There are some issues with your selectors, it should be '.Titleinner' instead of 'Titleinner'.

More importantly, you're mixing single and double quotes in your expressions which is what's breaking things and preventing the request from being made.

For example, replace the following line:

    expression:'element.getElementsBySelector('a')[0].textContent'

with:

    expression:'element.getElementsBySelector("a")[0].textContent'

@ilbambino
Copy link

True, the doc says that if there are errors it probably is a problem with the definition, but as I saw that one I skipped that part. Anyway, with this one works now:

{
  search: [
    {
      type:'link',
      query:'https://www.diigo.com/search?adSScope=my&what={{term}}&snapshot=no',
      translate:'parseHTML(response)',
      name:{
        selector:'.Titleinner',
        expression:'element.textContent.trim()'
      },
      link:{
        selector:'.Titleinner',
        expression:'element.firstElementChild.href'
      },
      description:{
        selector:'.Titleinner',
        expression:'element.textContent.trim()'
      }
    }
  ]
}

@olegp
Copy link
Contributor Author

olegp commented Jul 15, 2014

Works great, thanks! Can you please create a pull request or commit directly to master?

@olegp olegp closed this as completed in 608a1e3 Jul 15, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants