Skip to content

Commit 74dda93

Browse files
authored
Update HyperSearch.ahk
Added catch for importing duplicate categories from Chrome. Modified replace function for illegal characters in Chrome link labels.
1 parent b4f5365 commit 74dda93

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

HyperSearch.ahk

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,7 @@ AppendLinks:
550550
; Sample: 1Category+2LinkIndex+3LinkName+4URL
551551
linkTxt:=StrSplit(UsrIn,"+",,4)
552552
linkIndex:=linkTxt[2]
553+
;linkMax:=linkTxt.MaxIndex()
553554
;MsgBox % indexLabel . "`n" . linkIndex . "`n" . linkName . "`n" . linkURL
554555
if (linkTxt[1] != "") { ; Add new category
555556
Loop % HSR_Array.MaxIndex()
@@ -579,10 +580,14 @@ AppendLinks:
579580
break
580581
}
581582
}
582-
} else { ; Add category with blank first entry
583+
} else if (SubStr(UsrIn,0) == "+") { ; Add category with blank first entry
583584
appendTxt:="`n""" . linkTxt[1] . """," . """[ ]()"""
584585
FileAppend, %appendTxt%, %repo%
585586
;return
587+
} else {
588+
searchQuery = %UsrIn%
589+
GoSub, GoogleSearch
590+
return
586591
}
587592
mouseKeep:=1
588593
newCat:=linkTxt[1]
@@ -889,15 +894,19 @@ ImportChrome:
889894
replace:=0
890895
otherChk:=0
891896
search:=StrSplit(UsrIn,">",,2)
897+
bkmkLines:=[]
898+
;MsgBox % "Link: " . search[2]
899+
bkmkPath:=search[2]
900+
FileRead, bkmk, %bkmkPath%
901+
if (ErrorLevel == 1) {
902+
Msgbox % "File could not be read."
903+
return
904+
}
892905
MsgBox, 3, Import options, How would you like to import?`nYes: Append to current links`nNo: Replace all links with bookmarks
893906
IfMsgBox, No
894907
replace:=1
895908
IfMsgBox, Cancel
896909
return
897-
bkmkLines:=[]
898-
;MsgBox % "Link: " . search[2]
899-
bkmkPath:=search[2]
900-
FileRead, bkmk, %bkmkPath%
901910
Loop, Parse, bkmk, `n, `r ; Build HSR_Array
902911
{
903912
;MsgBox, % A_LoopField
@@ -931,6 +940,17 @@ ImportChrome:
931940
;MsgBox, Ding
932941
thisCat := " Bookmarks bar"
933942
}
943+
Loop % HSR_Array.MaxIndex()
944+
{
945+
;match := InStr(index,HSR_Array[A_Index,1])
946+
;MsgBox % HSR_Array[A_Index,1] . "`n" . index
947+
if (thisCat = HSR_Array[A_Index,1]) {
948+
ogCat := thisCat
949+
thisCat.="_1"
950+
;MsgBox % "Category " . ogCat . " already exists.`nThe category will be added as " . thisCat . "."
951+
;return
952+
}
953+
}
934954
fullArray[catIndex,1]:=thisCat
935955
nxtTab:=numTabs+1
936956
i:=A_Index+2
@@ -1075,10 +1095,10 @@ return
10751095

10761096
CleanLabels:
10771097
labelReplace := StrReplace(subLabel[1], "|", "-")
1078-
labelReplace := StrReplace(labelReplace, ")", "-")
1079-
labelReplace := StrReplace(labelReplace, "(", "-")
1080-
labelReplace := StrReplace(labelReplace, "[", "-")
1081-
labelReplace := StrReplace(labelReplace, "]", "-")
1098+
labelReplace := StrReplace(labelReplace, ")", "}")
1099+
labelReplace := StrReplace(labelReplace, "(", "{")
1100+
labelReplace := StrReplace(labelReplace, "[", "{")
1101+
labelReplace := StrReplace(labelReplace, "]", "}")
10821102
labelReplace := StrReplace(labelReplace, "`%5C", "\")
10831103
labelReplace := StrReplace(labelReplace, "+", A_Space)
10841104
labelReplace := StrReplace(labelReplace, "`%25", "`%")

0 commit comments

Comments
 (0)