Closing a Safari tab

Here’s the log. It has the missing value I’ve had since you first tried java with me:

Hello.

We crossposted! See my post above yours. Your log is not a pretty sight. :confused:

Hi. Still not working. :frowning: It is the mysterious missing value. I am confident this is a really weird issue and completely the same as the standard applescript issue earlier.

Hello.

I am more of the opionion that this is a totally different issue.

Please see if it works when you aren’t in full screeen mode. I am dead sure it doesn’t!

Interesting. The java doesn’t work in normal windows and the applescript one did…

Hello.

I think it either some plugin (still) that does something with your javascript, or that Facebook injects something into javascript for security measures or whatever.

For now, I suggest you stick to the applescript version, and see to that your windows aren’t full screen before you run it. (Shouldn’t be that hard.) :slight_smile:

I’m finding that the JavaScript version works for some tabs and not others ” “not others” including Google and Facebook pages. The result from the ‘do JavaScript’ command is ‘missing value’ whether the tab closes or not.

Hello.

That is no wonder, with javascript, you can do all kinds of things. And I guess the sites doesn’t prioritze our need for using it to control the browser.
Maybe if one where skilled, one could hijack back. But frankly, there is much more interesting things to keep me occupied, than drown inside the web inspector’s console. :slight_smile: GDB is far more interesting. :smiley:

I also believe that some of the Safari plugins utilizes javascript, but I am not totally sure about that.

I’m disappointed in Apple, full screens should be as scriptable as windows!

Thanks so much guys! :slight_smile:

(PS If you like GDB and stuff, try this: http://stackoverflow.com/questions/16970413/instance-variable-released people are stuck atm :stuck_out_tongue: and there is a small chance ASOC is involved, I would have posted here but I thought it was an Obj-C question!)

Hello.

I really liked the idea of pruning Safari Tabs, so I updated the script in post #6 to care of the pages that it can become and abundance of. :slight_smile:

Hello.

I updated the script in post #6 once again, so that it closes any pages open from that site.

The words in the tabnames must be unique for this to work. Edit the list at your own discretion.

You’d rather not have Macscripter there, if you have any open tabs with scripts that you care to read before you close.

Hello.

I have updated the script in post #25 for returning process number for a name, and killing them optionally, I have also updated the contents of the link in that post.

I fixed an abnormal issue, when you select from the history list, and there was nothing in there.

Hello.

The last version of the script that prunes some “Standard-tabs” in Safari, had the bug, that it closed the Standard tab if it was the current tab in the frontmost window. that is now fixed. The script is in post #6. And I am sorry for any inconvenience.

Hello.

The Prune Safari Script was meant to both save clutter, and resoures. The script below, must be saved as an applet, with the appropriate max number of finder windows you want to have open at all times. It will delete the oldest window that are above the threshold. It check every 15 minutes, and really saves resources, if you sometimes forget to close Finder Windows.

property tlvl : me
property NUMBER_TO_SAVE : 15
script pruneWindows
	tell application "Finder"
		set al to id of its every Finder window
	end tell
	set ct to count al
	if ct > NUMBER_TO_SAVE then
		set theLeft to 1
		set theRight to (count al)
		tlvl's quickSort(al, theLeft, theRight)
		script o
			property l : {}
		end script
		set o's l to al
		tell application "Finder"
			repeat with i from 1 to (ct - NUMBER_TO_SAVE)
				tell its Finder window id (item i of o's l) to close
			end repeat
		end tell
	end if
end script

on run
	tell pruneWindows to run
end run

on idle
	tell pruneWindows to run
	return 900
end idle

on quickSort(theList, theLeft, theRight)
	set i to theLeft
	set j to theRight
	set v to item ((theLeft + theRight) div 2) of theList -- pivot
	repeat while (j > i)
		repeat while (item i of theList < v)
			set i to i + 1
		end repeat
		repeat while (item j of theList > v)
			set j to j - 1
		end repeat
		if (not i > j) then
			tell theList to set {item i, item j} to {item j, item i} -- swap
			set i to i + 1
			set j to j - 1
		end if
	end repeat
	if (theLeft < j) then quickSort(theList, theLeft, j)
	if (theRight > i) then quickSort(theList, i, theRight)
end quickSort