Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Explicit
- Sub FindURLs()
- ' v0.2 2014-06-03 Jefferson Scher (Word 2010) NO WARRANTIES!
- ' Try to extract URLs from sessionstore file opened as a document
- Dim strTemp As String, arrWindows() As String, lngWindows As Long
- ' Get session history for open windows, discard closed windows
- strTemp = Split(ActiveDocument.Content.Text, ",""_closedWindows"":[")(0)
- ' Create an array of windows
- arrWindows = Split(strTemp, "{""tabs"":[")
- ' Create an output document
- Dim docNew As Word.Document
- Set docNew = Application.Documents.Add
- docNew.PageSetup.Orientation = wdOrientLandscape
- docNew.Content.InsertAfter "URLs from sessionstore"
- ' Iterate over windows
- Dim arrEntries() As String, lngEntries As Long, arrURLs() As String, lngURLs As Long, strURL As String
- For lngWindows = 1 To UBound(arrWindows)
- docNew.Content.InsertAfter vbCrLf & "Window " & lngWindows & ":"
- ' Discard closed tabs and identify history entries
- strTemp = Split(arrWindows(lngWindows), ",""_closedTabs"":[")(0)
- arrEntries = Split(strTemp, "{""entries"":[")
- ' Iterate over tabs
- For lngEntries = 1 To UBound(arrEntries)
- docNew.Content.InsertAfter vbCrLf & vbTab & "Tab " & lngEntries & " History (oldest to newest):"
- ' Discard children URLs (are these iframes??) and create array of URLs (tab history)
- strTemp = Split(arrEntries(lngEntries), ",""children"":[")(0)
- arrURLs = Split(strTemp, "{""url"":""")
- For lngURLs = 1 To UBound(arrURLs)
- strURL = Left(arrURLs(lngURLs), InStr(1, arrURLs(lngURLs), """") - 1)
- docNew.Content.InsertAfter vbCrLf & vbTab & vbTab & strURL
- Next
- Next
- Next
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement