Safari won't save history

Discussion in 'iPod touch Hacks' started by erifash, Sep 27, 2008.

  1. erifash macrumors newbie

    Joined:
    Jan 4, 2008
    #1
    After upgrading my iPod Touch to 2.0.2 and jailbreaking using QuickPwn, Safari will save my bookmarks but not my history.

    I went into /mobile/Library/Safari to check it out and there was a History.plist, but it remained at a constant 95 bytes, no matter how many websites I visited. I backed up the History.plist and deleted it to see if Safari would make a new one. It didn't. Although Safari does keep my history in memory until I close all tabs.

    So Safari will write to Bookmarks and SuspendState, but not History. I have tried changing the permissions and using chown, but it didn't work.

    I am writing a small ruby script with functionality similar to HistoryDL and I have been using SuspendState.plist instead, with limited success. It would really help if I could access my actual history...

    Anyone know what I could do?
     
  2. erifash thread starter macrumors newbie

    Joined:
    Jan 4, 2008
    #2
    Ruby source code

    I figured I might as well post the code I have so far...

    I'm just learning ruby but I figured out why SuspendState.plist wasn't working some of the time so I fixed my code. Frankly, the only people that should be using this are those who know their way around the terminal, so I don't think I have to explain all the details. :) The script should work anywhere you put it.

    This script does NOT read your history. Instead, it uses Safari's SuspendState so what you want to download MUST be open in a tab. It will prompt you for what tab you want to download.

    Code:
    require 'open-uri'
    
    plist = "/private/var/mobile/Library/Safari/SuspendState.plist"
    dir = "/private/var/mobile/Library/Downloads/"
    
    url = ""
    file = ""
    
    begin
        File.open(plist, "r") do |state|
            url = state.read.scan(/[a-z]+:\/\/.+#/).to_a.collect { |x| x.to_s.chomp("#") }
        end
    rescue Errno::ENOENT 
        puts "Error opening SuspendState.plist"
        Process.exit
    rescue NoMethodError
        puts "No entries in SuspendState.plist"
        Process.exit
    rescue
        raise $!
    end
    
    begin
        count = 0
        url.each do |str|
            count += 1
            puts "[" + count.to_s + "] " + str
        end
        print "Item: "
        item = gets.chomp.to_i - 1
        if item < 0 or item > count - 1
            puts "Item does not exist"
            Process.exit
        end
        url = url[item]
        file = url.split("/", -1).last
        file = file.empty? ? dir + "index.htm" : dir + file
        puts file
    rescue NoMethodError
        puts "Item does not exist"
        Process.exit
    rescue
    	raise $!
    end
    print "Confirm? (y/n) "
    if gets.chomp != "y"
        Process.exit
    end
    
    begin
        open(url) do |stream|
            begin
                File.open(file, "w+") do |f|
                    f.print stream.read
                end
            rescue Errno::ENOENT
                puts "Error opening file"
                Process.exit
            rescue
                raise $!
            end
        end
    rescue Errno::ENOENT
        puts "Error opening URL"
        Process.exit
    rescue SocketError
        puts "No internet connection"
        Process.exit
    rescue OpenURI::HTTPError
        puts "URL does not exist"
        Process.exit
    rescue
        raise $!
    end
    
    puts "Complete."
    
    Again, I apologize for the noobish code. :D
     

Share This Page