-
-
Save Stanzilla/9b881564eda628d830edd2ddcdff0b02 to your computer and use it in GitHub Desktop.
This is a KVIrc script that modifies the popup menu for URLs to include the page title. This means that there will be a delay before the menu appears, while the page is downloaded. Don't forget to disable the existing event handler.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
event(OnURLLinkPopupRequest,URLpopup) { | |
http.asyncGet -m=1048576 -t=10 -w=h ($0, $file.localdir(tmp\\title-preview)) { | |
popup.show urlpopup $0 $1 $2 $3; | |
} | |
} | |
defpopup(urlpopup) { | |
prologue { | |
%:status = $0; | |
%:title_found = $false; | |
%:title = ""; | |
%title_open = -1; | |
%title_close = -1; | |
if ($0 == 1) { | |
// Read in the file. | |
%data = $file.read($2, 1048576); | |
// Find the HTML title. | |
%title_open = $str.findfirst(%data, "<title>", $false, 0); | |
if (%title_open != -1) | |
%title_close = $str.findfirst(%data, "</title>", $false, $(%title_open + 7)); | |
if (%title_open != -1 && %title_close != -1) { | |
%:title = $str.mid(%data, $(%title_open + 7), $(%title_close - %title_open - 7)); | |
%:title_found = $true; | |
echo Page title: $k(2)%:title; | |
} | |
file.remove $2; | |
} | |
} | |
label(Page title:) (%:title_found) | |
label(%:title) (%:title_found) | |
label(No page title was found.) (%:status == 1 && !%:title_found) | |
label(The preview download failed.) (%:status != 1) | |
item(Open link,14) { | |
openurl $0 | |
} | |
item($tr("Copy To Clipboard","defscript"),259) { | |
str.toClipboard $0 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment