Skip to content

Instantly share code, notes, and snippets.

@Equim-chan
Last active May 17, 2018 09:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Equim-chan/3688a6ac67485e8355323001015eac77 to your computer and use it in GitHub Desktop.
Save Equim-chan/3688a6ac67485e8355323001015eac77 to your computer and use it in GitHub Desktop.
Chrome hack: use DuckDuckGo search engine with POST instead of GET.

POST version of DuckDuckGo in Chrome search

We can now drop the GET version of DuckDuckGo, such as

https://duckduckgo.com/?q=%s

and adopt the POST version below.

javascript:((document) => {
  var meta = document.createElement('meta')
  meta.name = 'referrer'
  meta.content = 'no-referrer'

  var form = document.createElement('form')
  form.method = 'POST'
  form.action = 'https://duckduckgo.com//'
  form.setAttribute('accept-charset', 'UTF-8')

  var input = document.createElement('input')
  input.name = 'q'
  input.value = `%s` (1)

  document.head.appendChild(meta)
  document.body.appendChild(form).appendChild(input)

  form.submit()
})(document)
  1. Hence the key word can contain " and ' but no `

minified version
javascript:(a=>{var b=a.createElement('meta'),c=a.createElement('form'),d=a.createElement('input');b.name='referrer',b.content='no-referrer',c.method='POST',c.action='https://duckduckgo.com//',c.setAttribute('accept-charset','UTF-8'),d.name='q',d.value=`%s`,a.head.appendChild(b),a.body.appendChild(c).appendChild(d),c.submit()})(document);
Note
It may not work when the current tab has some special Content Security Policy directives.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment