Copy Title and URL in single structure


FloatingMuseum

Recommended Posts

Hello

I need a possibility to copy Title and URL of the Tab not separately (as in Maxthon now) but in single structure with two fields: Title and Address. I know Maxthon can do this. Therefore, I have decided to write the plugin. The problem is I am newbie in JS and WebKit.

I think I have to use a Tab.title and a Tab.url. But I cannot find how to copy it to the clipboard.

I have tried to search WebKit API and found this: http://oldforum.maxthon.com/viewthread.php?tid=79469. But it is for html page's content not for WebKit Core.

Also, I cannot find how to define a keyboard shortcut for an addon.

Help, please.

Link to comment
Share on other sites

I've tried to do something very similar myself, and this is what I've come up with so far. It depends heavily on AutoHotKey. First, I assigned the "Copy Title and URL" action to Ctrl+Shift+z in Maxthon. Next, I added the following to my AutoHotKey script:$^+z::

send ^+z

IfWinActive ahk_class Maxthon3Cls_MainFrm

{

StringReplace, clipboard, clipboard, `r`n, =, All

FileAppend %clipboard% `r`n, f:\downloads\tabs.txt

return

}

returnThis code fires whenever you press Ctrl+Shift+z and re-sends the Ctrl+Shift+z (but doesn't fire itself in an infinite loop); if the active window is Maxthon (despite the Maxthon3Cls_MainFrm, this does work on Maxthon Cloud), it then reads the contents of the clipboard and replaces any newline with the equals sign (not a good idea for pages with equals signs in the URL, but works as a proof of concept), then appends the modified clipboard string to a file "f:\Downloads\tabs.txt"

Link to comment
Share on other sites

Hello,

I have this old plugin from Max 2. Don't know if you can get it to work in Max now.

Good luck!:)

//*************************************

//* *

//* Created by mdlist *

//* Visit mdlist.free.fr *

//* May be modified for personal use *

//* Please keep this credit *

//* *

//* ***********************************

var security_id=%max_security_id;

function no_error(){

return true;

}

onerror=no_error;

var selectedtext='';

try{

selectedtext=window.document.selection.createRange().text;

}

catch(asdf){

}

if(frames.length>0){

for(i=0;i

try{

selectedtext+=window.frames.document.selection.createRange().text;

}

catch(asdf){

}

}

}

selectedtext = (selectedtext.replace(/^\W+/,'')).replace(/\W+$/,'');

selectedtext=escape(selectedtext);

if (selectedtext) selectedtext="%AB"+selectedtext+"%BB%0D%0A%0D%0A%0D%0A";

var mdlist=0;

var url,title;

var mailmessage = selectedtext;

var alltabs=external.tab_count;

for (mdlist;mdlist

url=escape(external.get_tab(security_id,mdlist).document.URL);

if (external.get_tab(security_id,mdlist).document.title != ""){

title=escape(external.get_tab(security_id,mdlist).document.title)+":\n";

}

else title="";

mailmessage += title + url + "\n\n";

}

mailmessage = unescape(mailmessage);

window.clipboardData.setData("Text",mailmessage);

alert("The tabs info has been copied to the clipboard.");

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.