最近安装maxthon2.0,用来其delicious sidebar插件,原来工作正常,现在出现问题,卸载house重新安装sidebar,出现验证无法通过。检查其Delicious.js代码,由于原有网址http://del.icio.us,改为http://delicious.com/,所以无法验证,验证时必须有http://delicious.com/yourname网页打开,而且添加网址时标题不能超过255个字节。修改js如下:
- /**************************
- Del.icio.usSidebar
- ByNeo101
- Version1.2.1
- **************************/
- checkSettingsFile()
- varauthUser=readSetting('authUser')
- varsplit=authUser.split('%20')
- varuserName=split?split[0]:''
- varshowTooltip=readSetting('showTooltip','1')
- varautoUpdateTime=parseInt(readSetting('autoUpdateTime','0'))
- if(isNaN(autoUpdateTime)){
- autoUpdateTime=0
- }
- varsortTags=readSetting('sortTags','1')
- varsortFavorites=readSetting('sortFavorites','1')
- varuseBundles=readSetting('useBundles','1')
- varbaseURL='https://api.del.icio.us/v1/'
- varfavoritesCache='cache/favorites.html'
- varfavoritesHTML=''
- varposts=newArray()
- varbundleArray=newArray()
- varbranch=0
- varxmlhttp
- vareditElement
- varisAddFavorite=true
- varTRUE='1'
- varFALSE='0'
- //vardeliciousURL='http://del.icio.us/';
- vardeliciousURL='http://delicious.com/'
- vardeliciousSettingURL='https://secure.delicious.com/settings/'
- window.οnlοad=function(){
- if(authUser==''){
- displaySettings()
- document.getElementById('settingsLinks').style.display='none'
- document.getElementById('mainSettings').style.display='none'
- document.getElementById('links').style.display='none'
- document.getElementById('aboutDelicious').style.display=''
- }else{
- viewFavorites()
- getLastUpdateTime()
- setLinks()
- }
- setAutoUpdate()
- //cleanoldlogindata
- if(readSetting('userName','')!=''){
- writeSetting('userName','')
- writeSetting('password','')
- }
- }
- functionsetLinks(){
- document.getElementById('yourFavoritesLink').href=deliciousURL+userName
- document.getElementById('yourNetworkLink').href=deliciousURL+'network/'+userName
- document.getElementById('importBookmarksLink').href=deliciousSettingURL+userName+'/bookmarks/import'
- document.getElementById('exportBookmarksLink').href=deliciousSettingURL+userName+'/bookmarks/export'
- document.getElementById('editBundleLink').href=deliciousSettingURL+userName+'/tags/bundle?noredir'
- }
- functionsetAutoUpdate(){
- if(autoUpdateTime<5){
- return
- }
- vartime=autoUpdateTime*1000*60
- window.setInterval(getLastUpdateTime,time)
- }
- functionloadXMLDoc(url,type,stateChange,data){
- if(authUser==''){
- showError('Userinformationnotdefined!')
- return
- }
- try{
- xmlhttp=external.max_activex(SECURITY_ID,"Microsoft.XMLHTTP")
- }
- catch(err){
- try{
- xmlhttp=newActiveXObject("Microsoft.XMLHTTP")
- }
- catch(err){
- showError('CouldnotloadActiveXobject')
- }
- }
- xmlhttp.onreadystatechange=stateChange
- xmlhttp.open("POST",url,true,'cookie','cookie')
- xmlhttp.setRequestHeader('User-Agent','Maxthondel.icio.ussidebarplugin')
- xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded')
- xmlhttp.setRequestHeader('Referrer','Maxthondel.icio.ussidebarplugin')
- vardata='_user='+authUser
- xmlhttp.send(data)
- }
- functioncheckReadyState(obj){
- if(obj.readyState==4){
- //alert(obj.responseText)
- if(obj.status==200||obj.status==201){
- returntrue;
- }
- elseif(obj.status==401||obj.status==403){
- varmessage='Couldnotlogin.Pleasecheckyour'+
- '<ahref="#"οnclick="displaySettings()"style="color:red;text-decoration:underline">logininformation!</a>'
- showError(message)
- document.getElementById('favorites').innerHTML=message
- writeFile(favoritesCache,'')
- }
- elseif(obj.status==503){
- showError('Error503:Pleasetryagaininacoupleofminutes..')
- }
- else{
- showError(obj.status+''+obj.responseText);
- }
- }
- }
- functiongetLastUpdateTime(){
- varurl=baseURL+'posts/update?'+Math.round(Math.random()*1000)
- showError('Checkingforupdates...')
- loadXMLDoc(url,'getLastUpdateTime',onResponseGetLastUpdateTime)
- }
- functiononResponseGetLastUpdateTime(){
- if(!checkReadyState(xmlhttp)){
- return
- }
- varresponseXML=xmlhttp.responseXML
- if(responseXML==null){
- showError('ErrorloadingXML')
- return
- }
- try{
- varlastUpdateTime=responseXML.getElementsByTagName("update")[0].getAttribute('time')
- }catch(err){
- showError('badresponsegettingtime...')
- alert(xmlhttp.responseText)
- return
- }
- varpreviousUpdateTime=readSetting('UpdateTime')
- if(previousUpdateTime!=lastUpdateTime){
- showError('Updateavailable')
- writeSetting('UpdateTime',lastUpdateTime)
- window.setTimeout(updateFavorites,1000)
- }else{
- showError('Nofavoriteupdates')
- }
- }
- functionviewFavorites(){
- varhtml=unescape(readFile(favoritesCache))
- if(html==null||html==''){
- writeSetting('UpdateTime','')
- return
- }
- favoritesHTML=html
- currentlyOpenFolder=null
- document.getElementById('favorites').innerHTML=html
- }
- functiongetBundles(){
- varurl=baseURL+'tags/bundles/all?'+Math.round(Math.random()*1000)
- showError('Checkingforbundles...')
- loadXMLDoc(url,'getBundles',onResponseGetBundles)
- }
- functiononResponseGetBundles(){
- if(!checkReadyState(xmlhttp)){
- return
- }
- varresponseXML=xmlhttp.responseXML
- if(responseXML==null){
- showError('ErrorloadingBundleXML')
- return
- }
- bundleArray=newArray()
- varbundleTags=responseXML.getElementsByTagName("bundles")[0].childNodes
- for(vari=0;i<bundleTags.length;i++){
- bundleArray.push(newArray(bundleTags[i].getAttribute('name'),bundleTags[i].getAttribute('tags')))
- }
- window.setTimeout(downloadFavorites,1000)
- }
- functionupdateFavorites(){
- if(useBundles=='1'){
- getBundles()
- }else{
- downloadFavorites()
- }
- }
- functiondownloadFavorites(){
- varurl=baseURL+'posts/all?'+Math.round(Math.random()*1000)
- showError('Updating...')
- loadXMLDoc(url,'viewFavorites',onResponseViewFavorites)
- }
- functiononResponseViewFavorites(){
- if(!checkReadyState(xmlhttp)){
- return
- }
- varresponseXML=xmlhttp.responseXML
- if(responseXML==null){
- showError('ErrorloadingXML')
- return
- }
- varresponse=''
- posts=newArray()
- items=responseXML.getElementsByTagName("post");
- if(items&&items.length!=0){
- for(varj=0;j<items.length;j++){
- addPost(items[j],posts)
- }
- }
- else{
- response+='<b>Nofavoritesfound</b>'
- }
- vartags=newArray()
- addPostsToTags(posts,tags)
- if(sortTags=='1'){
- tags.sort()
- }
- response+=writeTree(tags)
- writeFile(favoritesCache,escape(response))
- favoritesHTML=response
- showError('FavoritesDownloaded')
- document.getElementById('favorites').innerHTML=response
- currentlyOpenFolder=null
- document.getElementById('searchbox').value=''
- }
- functiontitleSort(a,b){
- try{
- a=a.description.toLowerCase()
- b=b.description.toLowerCase()
- if(a<b){
- return-1
- }else{
- return1
- }
- }
- catch(err){
- return1
- }
- }
- functionaddPostsToTags(postsArray,tagsArray){
- for(vari=0;i<postsArray.length;i++){
- vartags=postsArray[i].tag.toLowerCase()
- vartagArray=tags.split('')
- for(varj=0;j<tagArray.length;j++){
- varposition=inArray(tagArray[j],tagsArray)
- if(position>=0){
- tagsArray[position][1].push(postsArray[i])
- }else{
- tagsArray.push(newArray(tagArray[j],newArray(postsArray[i])))
- }
- }
- }
- }
- functionwriteTree(tagsArray){
- varhtml=''
- varunfiledHtml=''
- for(vari=0;i<bundleArray.length;i++){
- varname=bundleArray[i][0]
- vartags=bundleArray[i][1].toLowerCase().split('')
- varbranchNumber=branch+10000
- html+=returnFolderHtml(branchNumber,name,true)
- html+=addTags(tags,tagsArray)
- html+='</div>/n'
- branch++
- }
- for(vari=0;i<tagsArray.length;i++){
- if(tagsArray[i][0]=='system:unfiled'){
- unfiledHtml=addLinks(tagsArray[i][1])
- continue
- }
- html+=returnTagHtml(tagsArray[i],true)
- }
- html+=unfiledHtml
- returnhtml
- }
- functionreturnFolderHtml(number,name,isBundle){
- if(isBundle!=null){
- varimageSrc='images/bundleClosed.gif'
- }else{
- varimageSrc='images/folderClosed.gif'
- }
- return'<divclass="trigger"οnclick="expandCollapse('+number+')"οncοntextmenu="showContextMenu(this);returnfalse"'+
- 'οnmοuseοver="this.style.textDecoration=/'underline/'"οnmοuseοut="this.style.textDecoration=/'none/'">'+
- '<imgsrc="'+imageSrc+'"border="0"id="folder'+number+'">'+
- name+
- '</div>/n<divclass="branch"id="branch'+number+'">'
- }
- functionaddTags(tags,tagsArray){
- varhtml=''
- for(vari=0;i<tags.length;i++){
- varposition=inArray(tags[i],tagsArray)
- if(position>-1){
- html+=returnTagHtml(tagsArray[position])
- }
- tagsArray.splice(position,1)
- }
- returnhtml
- }
- functionreturnTagHtml(tag,isHighBranch){
- if(isHighBranch!=null){
- varbranchNumber=branch+10000
- }else{
- varbranchNumber=branch
- }
- varhtml=returnFolderHtml(branchNumber,tag[0])
- html+=addLinks(tag[1])
- html+='</div>/n'
- branch++
- returnhtml
- }
- functionaddLinks(items){
- varhtml=''
- if(sortFavorites=='1'){
- items.sort(titleSort)
- }
- for(vari=0;i<items.length;i++){
- varitem=items[i]
- html+='<divclass=linkDivοncοntextmenu="showContextMenu(this);returnfalse">'+
- '<aclass=linkhref="'+item.href+'"target=_blanktitle="'+item.tooltip+'"'+
- 'οnmοuseοver="showLink(this.href)"οnmοuseοut="hideLink()"'+
- 'extended="'+item.extended+'"tag="'+item.tag+'"hashCode="'+item.hash+'">'+
- '<imgsrc="images/page.gif">'+
- item.description+
- '</a>'+
- '</div>/n'
- }
- returnhtml
- }
- functionaddPost(item,array){
- varhref=item.getAttribute('href')
- vardescription=item.getAttribute('description')
- vartag=item.getAttribute('tag')
- vartime=item.getAttribute('time')//.substring(0,10)
- varhash=item.getAttribute('hash')
- varextended=item.getAttribute('extended')
- if(extended==null){
- extended=''
- }
- //timeslike2004-09-16T00:00:00Z
- vardate=newDate()
- date.setISO8601(time)
- time=date.toLocaleString()
- if(showTooltip=='1'){
- vartooltip='Added:'+time
- varMAX_DESCRIPTION_LENGTH=30
- if(description.length>MAX_DESCRIPTION_LENGTH){
- tooltip=description+'/n'+tooltip
- }
- if(extended){
- tooltip+='/nNote:'+extended
- }
- }else{
- vartooltip=''
- }
- array.push({'href':href,
- 'description':description,
- 'tag':tag,
- 'time':time,
- 'hash':hash,
- 'extended':extended,
- 'tooltip':tooltip
- })
- }
- functiononResponsePostFavorite(){
- if(!checkReadyState(xmlhttp)){
- return
- }
- varresponseXML=xmlhttp.responseXML
- if(responseXML==null){
- showError('ErrorloadingXML')
- return
- }
- try{
- varresponse=responseXML.getElementsByTagName("result")[0].getAttribute('code')
- }catch(err){
- showError('badresponsePosting...')
- alert(xmlhttp.responseText)
- return
- }
- if(response=='done'){
- showError('Favoriteadded!')
- window.setTimeout('getLastUpdateTime()',1000)
- }
- }
- functiondeleteFavorite(url){
- varurl=baseURL+'posts/delete?url='+encodeURIComponent(url)
- showError('deleting...')
- loadXMLDoc(url,'deleteFavorite',onResponseDeleteFavorite)
- }
- functiononResponseDeleteFavorite(){
- if(!checkReadyState(xmlhttp)){
- return
- }
- varresponseXML=xmlhttp.responseXML
- if(responseXML==null){
- showError('ErrorloadingXML')
- return
- }
- try{
- varresponse=responseXML.getElementsByTagName("result")[0].getAttribute('code')
- }catch(err){
- showError('badresponseDeleting...')
- alert(xmlhttp.responseText)
- return
- }
- if(response=='done'){
- showError('Favoritedeleted!')
- window.setTimeout('getLastUpdateTime()',1000)
- }else{
- showError('Error:'+response)
- }
- }
- functiongetCurrentWebsiteURL(){
- returnexternal.get_tab(SECURITY_ID,external.cur_sel).document.URL
- }
- functiongetCurrentWebsiteTitle(){
- returnexternal.get_tab(SECURITY_ID,external.cur_sel).document.title
- }
- functiongetEditWebsiteURL(){
- returneditElement.href
- }
- functiongetEditWebsiteTitle(){
- returneditElement.innerText
- }
- functiongetEditWebsiteNotes(){
- returneditElement.extended
- }
- functiongetEditWebsiteTags(){
- returneditElement.tag
- }
- functiondisplaySettings(){
- loadSettings()
- document.getElementById('favorites').style.display='none'
- document.getElementById('settings').style.display=''
- document.getElementById('message').style.display='none'
- document.getElementById('menu').style.display='none'
- document.getElementById('showSettings').οnclick=function(){hideSettings()}
- }
- functiongetDeliciousCookie(){
- vardeliciousWindow=getDeliciousWindow()
- if(deliciousWindow==null){
- window.open(deliciousURL);
- }
- vardeliciousWindow=getDeliciousWindow()
- if(deliciousWindow){
- if(deliciousWindow.document.readyState=='complete'){
- saveCookie(deliciousWindow.document.cookie)
- }else{
- deliciousWindow.document.onreadystatechange=function(){
- if(deliciousWindow.document.readyState=='complete'){
- saveCookie(deliciousWindow.document.cookie)
- }
- }
- }
- }
- }
- functionsaveCookie(cookie){
- varmatch=cookie.match(/.*?_user=(.*?)(;|$)/)
- if(match){
- varuser=match[1]
- writeSetting('authUser',user)
- alert('Authenticated!')
- }else{
- writeSetting('authUser','')
- alert('Cookieproblem!/nCouldnotauthenticateyou./nMakesureyouareloggedintodelicious.com')
- }
- }
- functiongetDeliciousWindow(){
- varwin
- for(vari=0;i<external.tab_count;i++){
- win=external.get_tab(SECURITY_ID,i)
- if(win.document.URL.indexOf(deliciousURL)!=-1){
- returnwin
- }
- }
- returnnull
- }
- functionhideSettings(){
- document.getElementById('favorites').style.display=''
- document.getElementById('settings').style.display='none'
- document.getElementById('message').style.display='none'
- document.getElementById('menu').style.display=''
- document.getElementById('showSettings').οnclick=function(){displaySettings()}
- }
- functioncancel(){
- hideSettings()
- if(authUser==''){
- varmessage='<ahref="javascript:displaySettings()">Loginfirst!</a>'
- document.getElementById('favorites').innerHTML=message
- }
- }
- functionsave(){
- /*if(userName!=userNameNew){
- writeFile(favoritesCache,'')
- }*/
- writeSetting('UpdateTime','')
- saveSettings()
- location.reload()
- }
- functioninArray(text,array){
- for(vari=0;i<array.length;i++){
- if(text==array[i][0]){
- returni
- }
- }
- return-1
- }
- functionloadSettings(){
- varallInputTags=document.getElementsByTagName('input')
- for(vari=0;i<allInputTags.length;i++){
- if(allInputTags[i].type=='checkbox'){
- if(readSetting(allInputTags[i].id+'')==TRUE){
- allInputTags[i].checked=true
- }
- else{
- allInputTags[i].checked=false
- }
- }
- if(allInputTags[i].type=='text'&&allInputTags[i].id!='searchbox'&&allInputTags[i].οnkeydοwn==null){
- allInputTags[i].value=eval(allInputTags[i].id+'')
- }
- }
- }
- functionsaveSettings(){
- varallInputTags=document.getElementsByTagName('input');
- for(vari=0;i<allInputTags.length;i++){
- if(allInputTags[i].type=='checkbox'){
- if(allInputTags[i].checked==true){
- writeSetting(allInputTags[i].id+'',TRUE)
- }
- else{
- writeSetting(allInputTags[i].id+'',FALSE)
- }
- }
- if(allInputTags[i].type=='text'&&allInputTags[i].id!='searchbox'&&allInputTags[i].οnkeydοwn==null){
- writeSetting(allInputTags[i].id+'',allInputTags[i].value)
- }
- }
- }