nowplaying脚本更新,支持chrome

嗯,鉴于很多Mac用户用的是Chrome浏览器,于是做了个chrome版的,参考了github上的一段代码

放代码( > ◡╹)

1
tell application "iTunes"
	set trackName to name of current track
	set artistName to artist of current track
	set albumname to album of current track
	set timename to time of current track
end tell

on replaceChars(aString, charToReplace, newChar)
	set {TID, text item delimiters} to {text item delimiters, charToReplace}
	set aString to text items of aString
	set text item delimiters to newChar
	set aString to aString as text
	set text item delimiters to TID
	return aString
end replaceChars

set outputUrl to replaceChars("http://music.wayshine.us/nowplaying.php?album=" & albumname & "&artist=" & artistName & "&title=" & trackName & "&length=" & timename & "&from=233" & "&c=0", " ", "%20")


tell application "Google Chrome"
	activate
	set theUrl to outputUrl & "&s=0"

	if (count every window) = 0 then
		make new window
	end if

	set found to false
	set theTabIndex to -1
	repeat with theWindow in every window
		set theTabIndex to 0
		repeat with theTab in every tab of theWindow
			set theTabIndex to theTabIndex + 1
			if theTab's URL = theUrl then
				set found to true
				exit repeat
			end if
		end repeat

		if found then
			exit repeat
		end if
	end repeat

	if found then
		tell theTab to reload
		set theWindow's active tab index to theTabIndex
		set index of theWindow to 1
	else
		tell window 1 to make new tab with properties {URL:theUrl}
	end if
end tell

set the clipboard to outputUrl & "&s=3"