После открытия Mozilla Firefox (на версиях 15-18) в консоле ошибок каждые 2 секунды ошибка:
Метка времени: 12.01.2013 9:42:30
Ошибка: TypeError: this.switchSpeed is not a function
Источник: chrome://dmbar/content/dmbar.js
Строка: 579
Как бы это исправить.
С уважением, Евгений.
Ошибка: TypeError: this.switchSpeed is not a function
Moderators: Korney San, Qwertiy, Alex Qwerty, marcipan, igelizm, PAShYCh
А что в файле chrome://dmbar/content/dmbar.js?
Пожалуйста, посмотрите: Использование ссылок в тексте сообщений
Поддерживаются браузеры: Опера 12, Хром, Firefox.
Обновлено: 21.09.2012. Надо бы ещё подправить и обновить...
Ссылки на файлы обновлены: 24.05.2013.
Поддерживаются браузеры: Опера 12, Хром, Firefox.
Обновлено: 21.09.2012. Надо бы ещё подправить и обновить...
Ссылки на файлы обновлены: 24.05.2013.
Re:
Qwertiy wrote:А что в файле chrome://dmbar/content/dmbar.js?
Code: Select all
function DMBar() {
window.dmbar = this;
this.startup();
}
DMBar.prototype = {
settingsTimer : null,
videoTimer : null,
indicatorTimer: null,
videoFlashCount : 0,
exePath : "",
exeFile : null,
curVideo: "",
interceptor: null,
video: false,
videoLink: '',
_cookieManager: null,
tabLinks : {},
tabLinksExt : {},
_speed: "",
get speed() {
return this.readDMParam('SpeedMode');
},
set speed(value) {
this.setDMParam('SpeedMode', value);
return value;
},
_URLClipboardMonitoring: "",
get URLClipboardMonitoring() {
return this.readDMParam('URLClipboardMonitoring');
},
set URLClipboardMonitoring(value) {
this.setDMParam('URLClipboardMonitoring', value);
return value;
},
_urlDownload: "",
get urlDownload() {
return this.readDMParam('AddingURLOptions');
},
set urlDownload(value) {
this.writeDMParam('AddingURLOptions', value);
},
readDMParam: function (name) {
var wrk = CC["@mozilla.org/windows-registry-key;1"].createInstance(CI.nsIWindowsRegKey);
var val="";
try {
wrk.open(wrk.ROOT_KEY_CURRENT_USER,
"Software\\2VG\\Download Master",
wrk.ACCESS_READ);
val = wrk.readStringValue(name);
} catch (err) {
}
return val;
},
writeDMParam: function (name, value) {
var wrk = CC["@mozilla.org/windows-registry-key;1"].createInstance(CI.nsIWindowsRegKey);
var val="";
try {
wrk.open(wrk.ROOT_KEY_CURRENT_USER,
"Software\\2VG\\Download Master",
wrk.ACCESS_WRITE);
val = wrk.writeStringValue(name, value);
} catch (err) {
}
},
setDMParam: function (name, val) {
if (this.exeFile !== null) {
var proc = CC['@mozilla.org/process/util;1'].createInstance(CI.nsIProcess);
proc.init(this.exeFile);
var args = ['p='+name, 'v='+val];
proc.run(false,args,args.length,{});
}
},
getDMasterExe: function() {
var wrk = CC["@mozilla.org/windows-registry-key;1"].createInstance(CI.nsIWindowsRegKey);
var id = "";
try {
wrk.open(wrk.ROOT_KEY_CURRENT_USER,
"Software\\2VG\\Download Master",
wrk.ACCESS_READ);
id = wrk.readStringValue("ExeFile");
wrk.close();
} catch (err) {
return "";
}
this.exePath = id;
//return id;
},
addTabLink: function(tab, link, size, ext) {
function readablizeBytes(bytes) {
var s = ['bytes', 'kb', 'MB', 'GB', 'TB', 'PB'];
var e = Math.floor(Math.log(bytes)/Math.log(1024));
return (bytes/Math.pow(1024, Math.floor(e))).toFixed(2)+" "+s[e];
}
if (size<50000)
{
return;
}
if (typeof(this.tabLinks[tab]) === "undefined") {
this.tabLinks[tab] = [];
}
if (this.tabLinks[tab].indexOf(link+'$$$'+readablizeBytes(size))<0) {
this.tabLinks[tab].push(link+'$$$'+readablizeBytes(size));
this.tabLinksExt[link] = ext;
}
var tabID = gBrowser.selectedBrowser.parentNode.id;
if (tab===tabID) {
this.showTabVideo();
}
},
getTabLinks: function(tabID) {
return this.tabLinks[tabID];
//if (typeof(this.tabLinks[tabID]) == "object") {
// alert(this.tabLinks[tabID]);
//}
},
clearTabLinks: function (tabid) {
if (typeof(this.tabLinks[tabid]) === "object") {
this.tabLinks[tabid] = undefined;
}
},
showTabVideo: function() {
var tabID = gBrowser.selectedBrowser.parentNode.id;
var links = this.getTabLinks(tabID);
var sp = null;
this.turnButton("dm-get-video", false);
this.turnButton("dm-get-video-now", false);
if (typeof(links) === "undefined" ) {
return;
}
if (links.length === 0) {
return;
}
var button = document.getElementById("dm-get-video");
var menu = document.getElementById("dm-video-menu");
var button_now = document.getElementById("dm-get-video-now");
while (menu.firstChild) {
menu.removeChild(menu.firstChild);
}
if (links.length === 1) {
sp = links[0].split('$$$');
this.videoLink = sp[0];
//button_now.setAttribute('oncommand', 'window.dmbar.getVideoNow()');
this.turnButton("dm-get-video-now", true);
return;
} else {
this.videoLink = null;
// button_now.setAttribute('oncommand', '');
}
for (link_i in links) {
var item = document.createElement('menuitem');
sp = links[link_i].split('$$$');
item.setAttribute('label', sp[0].slice(0,50)+' ( '+sp[1]+' )');
item.setAttribute('oncommand', 'window.dmbar.runDM("'+sp[0]+'", false, true)');
menu.appendChild(item);
}
this.turnButton("dm-get-video", true);
},
getVideoNow: function() {
if (!this.videoLink) { return; }
this.runDM(this.videoLink, false, true);
},
getCookieManager: function() {
return this._cookieManager ? this._cookieManager : this._cookieManager =
CC["@mozilla.org/cookiemanager;1"
].getService(CI.nsICookieManager);
},
getCookies: function(link) {
var ios = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var uri = ios.newURI(link, null, null);
var cookieSvc = Components.classes["@mozilla.org/cookieService;1"]
.getService(Components.interfaces.nsICookieService);
var cookie = cookieSvc.getCookieString(uri, null);
return cookie;
},
loadJS: function (script, obj) {
var loader = CC["@mozilla.org/moz/jssubscript-loader;1"]
.getService(CI.mozIJSSubScriptLoader);
loader.loadSubScript("chrome://dmbar/content/lib/"+script+".js", obj);
},
searchTitle: function()
{
var document = window._content.document;
var host = document.location.host;
try
{
if (host==="www.youtube.com") {
return document.getElementById("watch-headline-title").firstChild.nextSibling.title;
}
if (host==="vkontakte.ru") {
return document.getElementById("header").firstChild.lastChild.textContent.substring(3, 255);
}
}
catch (err)
{ }
return "";
},
initCookies: function(links) {
var host, cookies, j, objCookie;
var hostCookies = {};
this.cookieManager = this.getCookieManager();
var l, parts;
for (j = links.length; j-- > 0;) {
l = links[j];
parts = l.match(/http[s]{0,1}:\/\/([^\/]+\.[^\/]+)/i); // host?
if (parts) {
host = parts[1];
var hpos = host.indexOf("@");
if (hpos > -1) {
host = host.substring(hpos + 1);
}
hostCookies[l.host = host] = "";
} else {
l.host = null;
}
}
var cookieHost, cookieTable, tmpCookie;
var domainCookies={};
var iter;
for (iter = this.cookieManager.enumerator; iter.hasMoreElements();) {
if ((objCookie = iter.getNext()) instanceof CI.nsICookie) {
cookieHost = objCookie.host;
if (cookieHost.charAt(0) === ".") {
cookieHost = cookieHost.substring(1);
cookieTable = domainCookies;
if (typeof(tmpCookie=domainCookies[cookieHost]) !== "string") {
tmpCookie = "";
}
} else {
if (typeof(tmpCookie=hostCookies[cookieHost]) !== "string") {
continue;
}
cookieTable = hostCookies;
}
cookieTable[cookieHost] = tmpCookie.concat(objCookie.name + "=" + objCookie.value + "; ");
}
}
var hostCookie;
for (hostCookie in hostCookies) {
var dotPos;
for (host = hostCookie; (dotPos=host.indexOf('.'))>=0; ) {
if ((tmpCookie == domainCookies[host])) {
hostCookies[cookieHost] += tmpCookie;
}
host = host.substring(dotPos+1);
}
}
return hostCookies[cookieHost];
},
runDM: function(path, all, video) {
var title = "";
var ext = "";
if (video)
{
title = this.searchTitle();
ext = this.tabLinksExt[path];
}
if (this.exeFile !== null) {
var proc = CC['@mozilla.org/process/util;1'].createInstance(CI.nsIProcess);
proc.init(this.exeFile);
if (!path) {
proc.run(false,null,0,{});
return ;
}
if ((path.indexOf('http')===0 || path.indexOf('ftp')===0 ||
path.indexOf('.htm')!==0) ) {
var referer = window.content.location.href;
var url = path;
//const cookie = this.getCookies(url);
path.href = path;
var cookie = this.initCookies([path]);
if (video)
{
if (title === "") {
title = document.title;
}
title += ext;
}
var downloadDescription = '<url>'+path+'</url>'+
'<referer>'+referer+'</referer>'+
'<cookies>'+cookie+'</cookies>'+
'<filename>'+title+'</filename>';
this.urlDownload = downloadDescription;
//this.log('url: '+url+'\n'+'referer: '+referer+'\n'+cookie+'\n');
//var args = [url, referer, cookie];
var args = [];
if (all) {
args = ['ALL', referer, url];
} else
{
args = ['-addurl'];
}
proc.run(false,args,args.length,{});
} else
if (path.indexOf('about')===0) {
proc.run(false,['-addurl'],1,{});
}
else
// if (video) {
// this.urlDownload = path;
// this.urlReferer = window.content.location.href;
// proc.run(false,['-addurl'],1,{});
// } else
{
proc.run(false,null,0,{});
}
} else {
window.openDialog("chrome://dmbar/content/dm_dialog.xul", "",
"chrome, dialog, modal, centerscreen, resizable=no", null).focus();
window.setTimeout(function(){
gBrowser.selectedTab = gBrowser.addTab("http://www.westbyte.com/dm/index.phtml?page=download&tmp=1&lng=Russian");
}, 500);
}
},
setupDragDrop: function()
{
var dragplace = document.getElementById('dm-drag-place');
dragplace.addEventListener("dragover", window.dmbar.dragOver, true);
dragplace.addEventListener("dragdrop", window.dmbar.dragDrop, true);
window.dmbar.checkRegistry();
},
dragOver: function(aEvent) {
var dragService = CC["@mozilla.org/widget/dragservice;1"].getService(CI.nsIDragService);
var dragSession = dragService.getCurrentSession();
var supported = dragSession.isDataFlavorSupported("text/x-moz-url");
if (supported) {
dragSession.canDrop = true;
}
},
dragDrop: function(aEvent) {
var dragService = CC["@mozilla.org/widget/dragservice;1"].getService(CI.nsIDragService);
var dragSession = dragService.getCurrentSession();
// Setup a transfer item to retrieve the file data
var trans = CC["@mozilla.org/widget/transferable;1"].createInstance(CI.nsITransferable);
trans.addDataFlavor("text/x-moz-url");
for (var i=0; i<dragSession.numDropItems; i++) {
var uri = null;
dragSession.getData(trans, i);
var flavor = {}, data = {}, length = {};
trans.getAnyTransferData(flavor, data, length);
var str = "";
if (data) {
try {
str = data.value.QueryInterface(CI.nsISupportsString);
}
catch(ex) {
}
if (str) {
uri = str.data.split("\n")[0];
}
}
if (uri) {
window.dmbar.runDM(uri, false);
}
}
},
startup: function() {
this.tabLinks = []; //new Array();
this.exepath = this.getDMasterExe();
if (this.exePath !== "") {
this.exeFile = CC["@mozilla.org/file/local;1"].createInstance(CI.nsILocalFile);
this.exeFile.initWithPath(this.exePath);
} else {
//show message
}
},
onLoad: function() {
this.loadJS('utils');
var prefs = CC["@mozilla.org/preferences-service;1"]
.getService(CI.nsIPrefBranch);
this.loadJS('listener');
this.loadJS('tracingListener');
this.loadJS('httpObserver', DMBar);
window.dmbar.setupDragDrop();
settingsTimer = setInterval(window.dmbar.checkRegistry, 2000);
indicatorTimer = setInterval(window.dmbar.updateIndicator, 1000);
},
getAll: function() {
var file = CC["@mozilla.org/file/local;1"].createInstance(CI.nsILocalFile);
var path = "C:\\Windows\\Temp\\dm_"+Math.ceil(Math.random()*1000000)+".htm";
file.initWithPath(path);
var wbp = CC['@mozilla.org/embedding/browser/nsWebBrowserPersist;1']
.createInstance(CI.nsIWebBrowserPersist);
wbp.saveDocument(content.document, file, null, null, null, null);
this.runDM(path, true);
},
doSearch: function() {
searchText = document.getElementById("dmSearchText");
var text = searchText.value;
var type = document.getElementById("dmSearchType").value;
if (text==="") {
return;
}
try {
if (searchText.hasAttribute("autocompletesearchparam")) {
var nativeJSON = CC["@mozilla.org/dom/json;1"].createInstance(CI.nsIJSON);
ausp = searchText.getAttribute("autocompletesearchparam");
words = nativeJSON.decode(ausp);
var word = { "value" : text, "comment" : null };
var hasVal = false;
for(var i=0;i<words.length;i++) {
if (words[i].value==text) {
hasVal = true;
break;
}
}
if (!hasVal) {
words.push(word);
ausp = nativeJSON.encode(words);
searchText.setAttribute("autocompletesearchparam", ausp);
/*
var prefs = CC["@mozilla.org/preferences-service;1"].getService(CI.nsIPrefBranch);
prefs.setCharPref("dmbar.searchHistory", ausp);
*/
}
}
} catch (e) {}
var url = 'http://topdownloads.ru/search.php?source=ffbar&ss='+text;
if (type !== "") { url = url + '&category=' + type; }
this.openURL(url);
},
turnButton: function(name, state) {
var button = document.getElementById(name);
if (!button) {
return ;
}
if (state) {
button.setAttribute("hidden", "false");
} else {
button.setAttribute("hidden", "true");
}
},
checkVideo: function(url, host, path) {
this.turnButton("dm-get-video", false);
this.turnButton("dm-video-sep", false);
this.videoFlashCount = 0;
if (this.videoTimer) {
clearInterval(this.videoTimer);
}
this.curVideo = "";
if (!host) {
return ;
}
if (host.indexOf('.youtube.com')>=0 && path.indexOf('/watch?v=')===0) {
this.curVideo = url;
}
//http://video.google.com/videoplay?docid=
if (host.indexOf('video.google.com')>=0 && path.indexOf('/videoplay?docid=')===0) {
this.curVideo = url;
}
//http://www.metacafe.com/watch/1759080/root_canal_treatment_procedure_mumbai_india/
if (host.indexOf('.metacafe.com')>=0 && path.indexOf('/watch')===0) {
this.curVideo = url;
}
//http://www.break.com/index/the-dumbest-women-on-the-highway.html
if (host.indexOf('.break.com')>=0 && path.indexOf('/index')===0) {
this.curVideo = url;
}
//http://rutube.ru/tracks/168294.html?v=7bbef648aba4b8d4a5e0a10f50953fa2
if (host.indexOf('rutube.ru')===0 && path.indexOf('/tracks')===0) {
this.curVideo = url;
}
//http://video.mail.ru
if (host.indexOf('video.mail.ru')===0) {
this.curVideo = url;
}
//http://vision.rambler.ru
if (host.indexOf('vision.rambler.ru')===0) {
this.curVideo = url;
}
//http://www.corbina.tv/flashplayer/player2.php?link=http://sansara.corbina.tv/videoout/add/private/491/20080503ironman.flv&idf=33702&ib=491&idc=2901
if (host.indexOf('corbina.tv')>=0 && path.indexOf('/flashplayer')===0) {
this.curVideo = url;
}
//http://video.bigmir.net/show/76436
if (host.indexOf('video.bigmir.net')===0 && path.indexOf('/show')===0) {
this.curVideo = url;
}
//http://play.ukr.net/videos/show/key/4cbfe031c6095174c523e744f204e88e/#ajax1
if (host.indexOf('play.ukr.net')===0 || host.indexOf('video.ukr.net')===0) {
this.curVideo = url;
}
this.turnButton("dm-get-video", this.curVideo!=="");
this.turnButton("dm-video-sep", this.curVideo!=="");
if (this.curVideo!=="") {
this.videoTimer = setInterval(window.dmbar.flashVideo, 500);
var button = document.getElementById("dm-get-video");
//button.showPopup(button, -1, -1, tooltip)
}
},
flashVideo : function(n) {
this.videoFlashCount += 1;
var button = document.getElementById("dm-get-video");
if (this.videoFlashCount == 14) {
clearInterval(this.videoTimer);
this.videoFlashCount = 0;
}
if (this.videoFlashCount % 2 == 1) {
button.setAttribute("image", "chrome://dmbar/skin/video2.png");
} else {
button.setAttribute("image", "chrome://dmbar/skin/video.png");
}
},
downloadVideo: function() {
if (this.curVideo !== "") {
this.runDM(this.curVideo, false);
}
},
checkRegistry: function() {
this.switchSpeed(this.speed);
this.showClipboard();
},
updateIndicator: function ()
{
var indicator = document.getElementById("dm-indicator");
if (indicator === null) {
return;
}
var url = indicator.getAttribute("image");
if (url.length<10)
{
url = 'file:///'+this.readDMParam('TempDir')+'indicator.bmp';
}
var no = 0;
if (url.indexOf('?')>0)
{
var parts = url.split('?');
no = parseInt(parts[1], 10);
url = parts[0];
}
no += 1;
url = url+'?'+no;
indicator.setAttribute("image", url);
},
showClipboard: function() {
var val = this.URLClipboardMonitoring;
var board = document.getElementById("dm-clipboard");
if (val=="0")
{ board.setAttribute("checked", "false"); }
else {
board.setAttribute("checked", "true");
}
},
switchClipboard: function () {
if ( this.URLClipboardMonitoring == "0" )
{
this.URLClipboardMonitoring = "1";
} else {
this.URLClipboardMonitoring = "0";
}
this.showClipboard();
},
setSpeed: function(val) {
this.speed = val;
this.switchSpeed(val);
},
switchSpeed: function(val) {
var speedButton = document.getElementById("dm-speed-button");
var element_id = "dm-max";
var element_ids = [
"max",
"avg",
"min",
"auto",
"manual"
];
var id = element_ids[val|0];
if (speedButton) {
speedButton.setAttribute("class", "toolbarbutton-1 speed-"+id);
}
var element = document.getElementById("dm-"+id);
if (element) {
element.setAttribute("checked", "true");
speedButton.setAttribute("tooltiptext", element.getAttribute("label"));
}
},
openURL: function (url) {
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var browserEnumerator = wm.getEnumerator("navigator:browser");
// Check each browser instance for our URL
var found = false;
while (!found && browserEnumerator.hasMoreElements()) {
var browserWin = browserEnumerator.getNext();
var tabbrowser = browserWin.getBrowser();
// Check each tab of this browser instance
var numTabs = tabbrowser.browsers.length;
for(var index=0; index<numTabs; index++) {
var currentBrowser = tabbrowser.getBrowserAtIndex(index);
if (url == currentBrowser.currentURI.spec) {
// The URL is already opened. Select this tab.
tabbrowser.selectedTab = tabbrowser.mTabs[index];
// Focus *this* browser-window
browserWin.focus();
found = true;
break;
}
}
}
// Our URL isn't open. Open it now.
if (!found) {
var recentWindow = wm.getMostRecentWindow("navigator:browser");
if (recentWindow) {
// Use an existing browser window
recentWindow.delayedOpenTab(url, null, null, null, null);
}
else {
// No browser windows are open, so open a new one.
window.open(url);
}
}
}
};
var dmbar = new DMBar();
window.addEventListener("load",
function (e) {
window.dmbar.onLoad();
window.getBrowser().addProgressListener(dmBarListener, CI.nsIWebProgress.NOTIFY_STATE_DOCUMENT);
}, false);
window.addEventListener("unload",
function () {
window.getBrowser().removeProgressListener(dmBarListener, CI.nsIWebProgress.NOTIFY_STATE_DOCUMENT);
}, false);