Skip to content

Instantly share code, notes, and snippets.

@Row
Last active January 19, 2019 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Row/d5a1065d89b4cc09bf798a1f30b52827 to your computer and use it in GitHub Desktop.
Save Row/d5a1065d89b4cc09bf798a1f30b52827 to your computer and use it in GitHub Desktop.
Filmtipset.se - Fix broken similar movie search
// ==UserScript==
// @name Filmtipset.se - Fix broken similar movie search
// @namespace https://github.com/Row/filmtipset-fix-broken-similar-movies
// @version 0.1
// @description Modified function from filmtipset.se. To access globals unsafeWindow is used
// @author Row
// @match http://www.filmtipset.se/film/*similar*
// @grant unsafeWindow
// ==/UserScript==
(function(window, $) {
'use strict';
// Function from movie_search.js on filmtipset.se
window.perform_search = function(counter, value, prefix) {
if (counter != window.last_counter) {
return;
}
if(value.length < 2) {
$('movie_list').style.display="none";
$('movie_list').innerHTML='';
return false;
}
if (value == window.last_value) {
return;
}
window.last_value=value;
window.ok_func = function (transport) { window.update_search(transport); };
window.failed_func = function (transport) { window.update_search(transport); };
// Here is the actual fix
// var url = '/filmtipset/ajax/get_movie_list.cgi'
var url = 'ajax/get_movie_list.cgi'
var pars = 'value='+value;
var myAjax = new window.Ajax.Request(
url,
{
method: 'get',
parameters: pars,
onSuccess: window.ok_func,
onFailure: window.failed_func
},
);
return false;
}
})(unsafeWindow, unsafeWindow.jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment