Code Monkey home page Code Monkey logo

Comments (4)

ilbambino avatar ilbambino commented on September 2, 2024

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.

from search.

olegp avatar olegp commented on September 2, 2024

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'

from search.

ilbambino avatar ilbambino commented on September 2, 2024

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()'
      }
    }
  ]
}

from search.

olegp avatar olegp commented on September 2, 2024

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

from search.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.