From 39292ad31bb5d360fc84d10f5b4b0cd7cb2b79ca Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Sat, 17 May 2014 21:59:07 -0400 Subject: [PATCH] Prevent hooks from triggering when we're not logged in. --- main.js | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/main.js b/main.js index 5bea008..e5073e9 100644 --- a/main.js +++ b/main.js @@ -405,6 +405,9 @@ function hook_edit(anime_id) { }); } +function hook_shared() { +} + function hook_addtolist() { /* TODO: this entry point is unimplemented - it's rarely used and difficult to inject into, so I'm avoiding it for now. */ @@ -419,14 +422,21 @@ function hook_addtolist() { $(document).ready(function() { var href = window.location.href; - if (href.indexOf("/animelist/") != -1) - hook_list(); - else if (href.indexOf("/anime/") != -1 || href.indexOf("/anime.php") != -1) - hook_anime(get_anime_id_from_href(href)); - else if (href.indexOf("/panel.php") != -1 && href.indexOf("go=add") != -1) - hook_add(); - else if (href.indexOf("/editlist.php") != -1 && href.indexOf("type=anime") != -1) - hook_edit(get_edit_id_from_href(href)); - else if (href.indexOf("/addtolist.php") != -1) - hook_addtolist(); + if (href.indexOf("/animelist/") != -1) { + var list_info = $("#mal_cs_otherlinks div:first"); + if (list_info.text() == "You are viewing your anime list") + hook_list(); + } + else if ($("#malLogin").length == 0) { + if (href.indexOf("/anime/") != -1 || href.indexOf("/anime.php") != -1) + hook_anime(get_anime_id_from_href(href)); + else if (href.indexOf("/panel.php") != -1 && href.indexOf("go=add") != -1) + hook_add(); + else if (href.indexOf("/editlist.php") != -1 && href.indexOf("type=anime") != -1) + hook_edit(get_edit_id_from_href(href)); + else if (href.indexOf("/shared.php") != -1) + hook_shared(); + else if (href.indexOf("/addtolist.php") != -1) + hook_addtolist(); + } });