Recognize more characters as next page and be more tolerant

This commit is contained in:
Christian Dywan 2010-05-26 22:41:13 +02:00
parent 5f8e9da610
commit c2be3d67cf

View file

@ -4657,12 +4657,38 @@ midori_view_get_previous_page (MidoriView* view)
web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view->web_view)); web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view->web_view));
js_context = webkit_web_frame_get_global_context (web_frame); js_context = webkit_web_frame_get_global_context (web_frame);
katze_assign (uri, sokoke_js_script_eval (js_context, katze_assign (uri, sokoke_js_script_eval (js_context,
"(function (l) { for (i in l) " "(function (l) {"
"if ((l[i].rel && l[i].rel == 'prev') " "var ind = ['prev','←','«','<'];"
" || (l[i].innerHTML" "var nind = ['next','→','»','>'];"
" && l[i].innerHTML.toLowerCase ().indexOf ('prev') != -1)) " "for (i in l)"
"{ return l[i].href; } return 0; })(" "if (l[i].rel && (l[i].rel == ind[0]))"
"document.getElementsByTagName ('a'));", NULL)); "return l[i].href;"
"for (j in ind)"
"for (i in l)"
"if (l[i].innerHTML"
"&& (l[i].innerHTML.toLowerCase ().indexOf (ind[j]) != -1)"
"&& (l[i].innerHTML.toLowerCase ().indexOf (nind[j]) == -1))"
"return l[i].href;"
"var wa = window.location.href.split (/\\d+/);"
"var wn = window.location.href.split (/[^\\d]+/);"
"wn = wn.slice (1,wn.length - 1);"
"var cand = [];"
"for (i in wn)"
"{"
"cand[i] = '';"
"for (j = 0; j <= i; j++)"
"{"
"cand[i] += wa[j];"
"if (wn[j])"
"cand[i] += parseInt (wn[j]) - ((i == j) ? 1 : 0);"
"}"
"}"
"for (j in cand)"
"for (i in l)"
"if (l[i].href && (l[i].href.indexOf (cand[j]) == 0))"
"return l[i].href;"
"return 0;"
"}) (document.getElementsByTagName ('a'));", NULL));
return uri && uri[0] != '0' ? uri : NULL; return uri && uri[0] != '0' ? uri : NULL;
} }
@ -4688,15 +4714,40 @@ midori_view_get_next_page (MidoriView* view)
web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view->web_view)); web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view->web_view));
js_context = webkit_web_frame_get_global_context (web_frame); js_context = webkit_web_frame_get_global_context (web_frame);
katze_assign (uri, sokoke_js_script_eval (js_context, katze_assign (uri, sokoke_js_script_eval (js_context,
"(function (l) { for (i in l) " "(function (l) {"
"if ((l[i].rel && l[i].rel == 'next') " "var ind = ['next','→','»','&gt;'];"
" || (l[i].innerHTML" "var nind = ['prev','←','«','&lt;'];"
" && l[i].innerHTML.toLowerCase ().indexOf ('next') != -1)) " "for (i in l)"
"{ return l[i].href; } return 0; })(" "if (l[i].rel && (l[i].rel == ind[0]))"
"document.getElementsByTagName ('a'));", NULL)); "return l[i].href;"
"for (j in ind)"
"for (i in l)"
"if (l[i].innerHTML"
"&& (l[i].innerHTML.toLowerCase ().indexOf (ind[j]) != -1)"
"&& (l[i].innerHTML.toLowerCase ().indexOf (nind[j]) == -1))"
"return l[i].href;"
"var wa = window.location.href.split (/\\d+/);"
"var wn = window.location.href.split (/[^\\d]+/);"
"wn = wn.slice (1,wn.length - 1);"
"var cand = [];"
"for (i in wn)"
"{"
"cand[i] = '';"
"for (j = 0; j <= i; j++)"
"{"
"cand[i] += wa[j];"
"if (wn[j])"
"cand[i] += parseInt (wn[j]) + ((i == j) ? 1 : 0);"
"}"
"}"
"for (j in cand)"
"for (i in l)"
"if (l[i].href && (l[i].href.indexOf (cand[j]) == 0))"
"return l[i].href;"
"return 0;"
"}) (document.getElementsByTagName ('a'));", NULL));
return uri && uri[0] != '0' ? uri : NULL; return uri && uri[0] != '0' ? uri : NULL;
} }
#if WEBKIT_CHECK_VERSION (1, 1, 5) #if WEBKIT_CHECK_VERSION (1, 1, 5)
static GtkWidget* static GtkWidget*
midori_view_print_create_custom_widget_cb (GtkPrintOperation* operation, midori_view_print_create_custom_widget_cb (GtkPrintOperation* operation,