How To add Search Engines that use POST to Vivaldi

There is a long standing problem with Vivaldi not adding every kind of search engines, e.g. the current implementation still does not add search engines like SearX

This happens because those engines use POST instead of GET in their search forms and Vivaldi does not (yet) check for that.

To mitigate the problem …

… you can use the following bookmarklet:

javascript:(function()%7Bvar%20x,i%3Bx%3Ddocument.forms%3Bfor(i%3D0%3Bi%3Cx.length%3B++i)x%5Bi%5D.method%3D%22get%22%3Balert(%22Changed%20%22%20+%20x.length%20+%20%22%20forms%20to%20use%20the%20GET%20method.%5Cn%5CnDON'T%20USE%20THE%20ALTERED%20PAGE%20NOW!%5Cn%5Cn%20-%20Right-click%20in%20the%20search%20field%5Cn%20-%20select%20%5C%22Add%20as%20search%20engine%5C%22%5Cn%20-%20Open%20%5C%22Settings%5C%22%20%3E%20%5C%22Search%5C%22%5Cn%20-%20Click%20the%20edit%20button%20for%20the%20new%20search%5Cn%20-%20Check%20%5C%22Use%20Post%5C%22%5Cn%5CnEnjoy!%22)%3B%7D)()%3B
  • Create a new bookmark in the panel and copy/paste the line above in the URL field of the Bookmarks panel.
  • Give it a name like e.g. “GET the POST search”.
  • Optional add a shortcut like “getit” too.

Now you can go to one of the search engine result pages 1), e.g. the one linked above and either click on the bookmarklet or type the shortcut in the URL bar and hit enter.

An alert-box with additional instructions will pop up. Follow the instructions.

Warning: The site will be altered by the bookmarklet. Don’t use it for a search before you have reloaded the page or else it might break!

1) It might not work if you try it on the start page of the search engine. In this case search for “test” and try applying the bookmarklet on the result page. Some search engine still might not work that way because they use other means and time based searches, but the majority should work just fine.

How it works

The bookmarklet changes all FORM elements on the page to use GET instead of POST. This allows right click > “Add as Search Engine” to detect it and enter the corresponding values it needs. Don’t forget to set the “Use POST Method” checkbox for the newly created search in “Vivaldi > Settings > Search”.

Here the decoded and unminified “source code”:


javascript: (function () {
var x, i;
x = document.forms;
for (i = 0; i < x.length; ++i) {
x[i].method = "get";
}
alert("Changed " + x.length + " forms to use the GET method.\n\nDON'T USE THE ALTERED PAGE NOW!\n\n - Right-click in the search field\n - select \"Add as search engine\"\n - Open \"Settings\" > \"Search\"\n - Click the edit button for the new search\n - Check \"Use Post Method\"\n\nEnjoy!");
})();

If the search engine does not use POST …

…but “Add as Search Engine …” entry still does not want to show up, see Adding Search Engines to the Vivaldi Browser (followup)

6 replies on “How To add Search Engines that use POST to Vivaldi”

  1. The code being executed is only a few lines so If they went through the trouble of adding the option to check the box for “POST in the search settings, why didn’t they just complete the ability for it’s execution by implementing that code to run automatically if the box is checked so we don’t have to jump through hoops for this to work?

    1. Well, my code is far from perfect, it is a quick hack.
      It changes the page (that’s why you really should reload before you interact with the page after using it), which might not be allowed on some sites because of content security policies the site has set, it might break other things which could lead to the browser being banned from entering the site because of “hacking” (and yes, it would be a kind of hacking), the resulting search might not work (I have seen such sites too), the final post request might be composed from the search field plus some stuff that is generated by Javascript (which fails with the bookmarklet), and so on, and so on. I don’t even need to think hard to find a bunch of other things where it might fail or have detrimental effects.

      As author of a bookmarklet I don’t have to think about all of that because the user of the bookmarklet uses it at its own risk, but all of this makes the integration in a final product much more difficult than just “fixing” the problem with the bookmarklet.

      1. No point, works perfectly fine as a bookmarklet. You could turn it into a page action by saving it to the application, but that would require the user to include the file in a batch script for updating Vivaldi, or redo the patching manually each time.

        1. Despite I apply my mods via batch script after each update, it was more meant like a joke 😀
          I know that the script doesn’t work for some pages, especially those tho use “DIV” instead of “INPUT type=search” etc, so it makes not much sense to integrate it that tightly – apart from that:
          How many searches does one person need?
          (I have 31 atm, but I definitely can and will delete some again because as they have proven to be not that useful)

Comments are closed.