extensions.easydragtogo.custom.saveT
extAs
if(target == "text" && url){var fp =
Components.classes
["@mozilla.org/filepicker;1"].createInst
ance
(Components.interfaces.nsIFilePicker);
fp.init(window, null, fp.modeSave);
fp.defaultExtension = "txt";
fp.defaultString = url.substr(0,
20).replace(/[\\\/\*\|\?\n:"<>]/g, "-") +
".txt"; fp.appendFilters(fp.filterText);
fp.appendFilters(fp.filterAll); if
(fp.show() != fp.returnCancel){var
conv = Components.classes
["@mozilla.org/intl/scriptableunicodec
onverter"].createInstance
(Components.interfaces.nsIScriptableU
nicodeConverter); conv.charset = 'UTF
-8'; var text =
conv.ConvertFromUnicode
(url).replace(/\n/g, "\r\n"); var stream =
Components.classes
["@mozilla.org/network/file-output-
stream;1"].createInstance
(Components.interfaces.nsIFileOutput
Stream); stream.init(fp.file,
0x02|0x20|0x08, 0666, 0);
stream.write
("\u00EF\u00BB\u00BF",3);
stream.write(text, text.length); var fin
= conv.Finish(); if(fin.length > 0)
stream.write(fin, fin.length);
stream.close();}}
if(target == "text" && url){var fp =
Components.classes
["@mozilla.org/filepicker;1"].createInst
ance
(Components.interfaces.nsIFilePicker);
fp.init(window, null, fp.modeSave);
fp.defaultExtension = "txt";
fp.defaultString = url.substr(0,
20).replace(/[\\\/\*\|\?\n:"<>]/g, "-") +
".txt"; fp.appendFilters(fp.filterText);
fp.appendFilters(fp.filterAll); if
(fp.show() != fp.returnCancel){var
conv = Components.classes
["@mozilla.org/intl/scriptableunicodec
onverter"].createInstance
(Components.interfaces.nsIScriptableU
nicodeConverter); conv.charset = 'UTF
-8'; var text =
conv.ConvertFromUnicode
(url).replace(/\n/g, "\r\n"); var stream =
Components.classes
["@mozilla.org/network/file-output-
stream;1"].createInstance
(Components.interfaces.nsIFileOutput
Stream); stream.init(fp.file,
0x02|0x20|0x08, 0666, 0);
stream.write
("\u00EF\u00BB\u00BF",3);
stream.write(text, text.length); var fin
= conv.Finish(); if(fin.length > 0)
stream.write(fin, fin.length);
stream.close();}}
没有评论:
发表评论