Advertisement
Guest User

Untitled

a guest
Dec 30th, 2017
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.78 KB | None | 0 0
  1. use AppleScript version "2.4"
  2. use scripting additions
  3. use framework "Foundation"
  4. use framework "AppKit"
  5.  
  6. property itemStatus : missing value
  7.  
  8. on run
  9. init() of me
  10. end run
  11.  
  12. on init()
  13. set menuList to {"๐Ÿšฆ Filter Bad Hosts", "๐Ÿ”“ Clean Filters", "", "โ†ช Change Wally", "", "โฌ† Update Site", "โฌ‡ Serve MkDocs", "", "โ™‚ Transmit", "", "โŒ˜ BBEdit", "โŒ˜ Script Editor", "โŒ˜ Automator", "", "โ„ CentOS", "โ„ Windoze", "", "โœ Dozer R/W", "โœ’ Dozer Read Only", "โ†• Mounty", "", "โ„น Show/Hide Files", "", "โ Eject Disks", "", "โคต AppDelete", "โ™ป Zap Trash", "", "โš• Preferences", "โŽ‹ Quit"}
  14. set itemStatus to current application's NSStatusBar's systemStatusBar()'s statusItemWithLength:(current application's NSVariableStatusItemLength)
  15. itemStatus's setTitle:"๐Ÿšฆ"
  16. itemStatus's setHighlightMode:true
  17. itemStatus's setMenu:(createMenu(menuList) of me)
  18. repeat
  19.  
  20. try
  21. do shell script "cat /etc/hosts |grep FULL_HOSTS_BLOCK"
  22. itemStatus's setTitle:"๐Ÿšฆ"
  23. on error
  24. itemStatus's setTitle:"๐Ÿ”“"
  25. end try
  26.  
  27. delay 60
  28.  
  29. end repeat
  30. end init
  31.  
  32. on createMenu(menuList)
  33. set theMenu to current application's NSMenu's alloc()'s init()
  34. set aCount to 1
  35. repeat with i in menuList
  36. set j to contents of i
  37. if j is not equal to "" then
  38. set menuItem to (current application's NSMenuItem's alloc()'s initWithTitle:j action:"actionHandler:" keyEquivalent:"")
  39. else
  40. set menuItem to (current application's NSMenuItem's separatorItem())
  41. end if
  42. (menuItem's setTarget:me)
  43. (menuItem's setTag:aCount)
  44. (theMenu's addItem:menuItem)
  45.  
  46. if j is not equal to "" then
  47. set aCount to aCount + 1
  48. end if
  49. end repeat
  50. return theMenu
  51. end createMenu
  52.  
  53. on getImage(folderName)
  54. tell application "Finder"
  55. return some file of folder ("Pictures:Wallpaper:" & folderName) of home as text
  56. end tell
  57. end getImage
  58.  
  59. on wally()
  60. set morning to "Morning"
  61. set afternoon to "Afternoon"
  62. set dawn to "DuskDawn"
  63. set night to "Night"
  64. set dusk to "DuskDawn"
  65. set h to hours of (current date)
  66. set timeNow to morning
  67. if (h > 8 and h < 12) then
  68. set timeNow to morning
  69. else if (h โ‰ฅ 12 and h < 18) then
  70. set timeNow to afternoon
  71. else if (h โ‰ฅ 18 and h < 20) then
  72. set timeNow to dawn
  73. else if (h โ‰ฅ 20 or h < 5) then
  74. set timeNow to night
  75. else if (h โ‰ฅ 5 or h < 8) then
  76. set timeNow to dusk
  77. end if
  78. tell application "Finder"
  79. try
  80. set displayPicture to my getImage(timeNow)
  81. set desktop picture to displayPicture
  82. end try
  83. end tell
  84. end wally
  85.  
  86. on actionHandler:sender
  87. set menuTitle to title of sender as string
  88.  
  89. if menuTitle is equal to "โŽ‹ Quit" then
  90. current application's NSStatusBar's systemStatusBar()'s removeStatusItem:itemStatus
  91. if (name of current application) is not "Script Editor" then
  92. tell current application to quit
  93. end if
  94.  
  95. else if menuTitle is equal to "๐Ÿšฆ Filter Bad Hosts" then
  96. do shell script "cp /etc/hosts.full /etc/hosts;dscacheutil -flushcache;killall -HUP mDNSResponder" with administrator privileges
  97. itemStatus's setTitle:"๐Ÿšฆ"
  98.  
  99. else if menuTitle is equal to "๐Ÿ”“ Clean Filters" then
  100. do shell script "cp /etc/hosts.clean /etc/hosts;dscacheutil -flushcache;killall -HUP mDNSResponder" with administrator privileges
  101. itemStatus's setTitle:"๐Ÿ”“"
  102.  
  103. else if menuTitle is equal to "โ†ช Change Wally" then
  104. itemStatus's setTitle:"โ†ช"
  105. wally()
  106. delay 1
  107. try
  108. do shell script "cat /etc/hosts |grep FULL_HOSTS_BLOCK"
  109. itemStatus's setTitle:"๐Ÿšฆ"
  110. on error
  111. itemStatus's setTitle:"๐Ÿ”“"
  112. end try
  113. else if menuTitle is equal to "โฌ† Update Site" then
  114. itemStatus's setTitle:"โฌ†"
  115. tell application "WebUp" to activate
  116. try
  117. do shell script "cat /etc/hosts |grep FULL_HOSTS_BLOCK"
  118. itemStatus's setTitle:"๐Ÿšฆ"
  119. on error
  120. itemStatus's setTitle:"๐Ÿ”“"
  121. end try
  122.  
  123. else if menuTitle is equal to "โฌ‡ Serve MkDocs" then
  124. itemStatus's setTitle:"โฌ‡"
  125. tell application "ServeMk" to activate
  126. try
  127. do shell script "cat /etc/hosts |grep FULL_HOSTS_BLOCK"
  128. itemStatus's setTitle:"๐Ÿšฆ"
  129. on error
  130. itemStatus's setTitle:"๐Ÿ”“"
  131. end try
  132.  
  133.  
  134. else if menuTitle is equal to "โ Eject Disks" then
  135. itemStatus's setTitle:"โ"
  136. set collection_1 to {}
  137. set diskList to {"All Disks"}
  138.  
  139. set mountedDiskName to "Dozer 7"
  140. set diskIsMounted to false
  141.  
  142. tell application "Finder"
  143. try
  144. set diskList to diskList & (name of every disk whose ejectable is true)
  145. on error
  146.  
  147. end try
  148. end tell
  149.  
  150. if (count of diskList) is greater than 1 then
  151. tell application "Finder"
  152. eject every disk
  153. end tell
  154. end if
  155.  
  156. tell application "System Events" to set diskNames to name of every disk
  157. if mountedDiskName is in diskNames then
  158. set diskIsMounted to true
  159. end if
  160.  
  161. if diskIsMounted then
  162. do shell script "diskutil unmount /dev/disk0s4"
  163. end if
  164.  
  165. try
  166. do shell script "cat /etc/hosts |grep FULL_HOSTS_BLOCK"
  167. itemStatus's setTitle:"๐Ÿšฆ"
  168. on error
  169. itemStatus's setTitle:"๐Ÿ”“"
  170. end try
  171.  
  172. else if menuTitle is equal to "โ™ป Zap Trash" then
  173. itemStatus's setTitle:"โ™ป"
  174. delay 1
  175. do shell script "rm -rf ~/.Trash/*" with administrator privileges
  176. try
  177. do shell script "cat /etc/hosts |grep FULL_HOSTS_BLOCK"
  178. itemStatus's setTitle:"๐Ÿšฆ"
  179. on error
  180. itemStatus's setTitle:"๐Ÿ”“"
  181. end try
  182.  
  183. else if menuTitle is equal to "โคต AppDelete" then
  184. itemStatus's setTitle:"โคต"
  185. do shell script "open /Applications/Tools/AppDelete.app"
  186. try
  187. do shell script "cat /etc/hosts |grep FULL_HOSTS_BLOCK"
  188. itemStatus's setTitle:"๐Ÿšฆ"
  189. on error
  190. itemStatus's setTitle:"๐Ÿ”“"
  191. end try
  192.  
  193. else if menuTitle is equal to "โŒ˜ Script Editor" then
  194. itemStatus's setTitle:"โŒ˜"
  195. tell application "Script Editor" to activate
  196. try
  197. do shell script "cat /etc/hosts |grep FULL_HOSTS_BLOCK"
  198. itemStatus's setTitle:"๐Ÿšฆ"
  199. on error
  200. itemStatus's setTitle:"๐Ÿ”“"
  201. end try
  202.  
  203. else if menuTitle is equal to "โŒ˜ Automator" then
  204. itemStatus's setTitle:"โŒ˜"
  205. do shell script "open /Applications/Automator.app"
  206. try
  207. do shell script "cat /etc/hosts |grep FULL_HOSTS_BLOCK"
  208. itemStatus's setTitle:"๐Ÿšฆ"
  209. on error
  210. itemStatus's setTitle:"๐Ÿ”“"
  211. end try
  212.  
  213. else if menuTitle is equal to "โŒ˜ BBEdit" then
  214. itemStatus's setTitle:"โŒ˜"
  215. do shell script "open /Applications/Editors/BBEdit.app"
  216. try
  217. do shell script "cat /etc/hosts |grep FULL_HOSTS_BLOCK"
  218. itemStatus's setTitle:"๐Ÿšฆ"
  219. on error
  220. itemStatus's setTitle:"๐Ÿ”“"
  221. end try
  222.  
  223. else if menuTitle is equal to "โ™‚ Transmit" then
  224. itemStatus's setTitle:"โ™‚"
  225. do shell script "open /Applications/Network/Transmit.app"
  226. try
  227. do shell script "cat /etc/hosts |grep FULL_HOSTS_BLOCK"
  228. itemStatus's setTitle:"๐Ÿšฆ"
  229. on error
  230. itemStatus's setTitle:"๐Ÿ”“"
  231. end try
  232.  
  233. else if menuTitle is equal to "โ„ CentOS" then
  234. itemStatus's setTitle:"โ„"
  235. do shell script "/usr/local/bin/VBoxManage startvm CentOS --type gui"
  236. try
  237. do shell script "cat /etc/hosts |grep FULL_HOSTS_BLOCK"
  238. itemStatus's setTitle:"๐Ÿšฆ"
  239. on error
  240. itemStatus's setTitle:"๐Ÿ”“"
  241. end try
  242.  
  243. else if menuTitle is equal to "โ„ Windoze" then
  244. itemStatus's setTitle:"โ„"
  245. do shell script "/usr/local/bin/VBoxManage startvm Slim7 --type gui"
  246. try
  247. do shell script "cat /etc/hosts |grep FULL_HOSTS_BLOCK"
  248. itemStatus's setTitle:"๐Ÿšฆ"
  249. on error
  250. itemStatus's setTitle:"๐Ÿ”“"
  251. end try
  252.  
  253. else if menuTitle is equal to "โš• Preferences" then
  254. itemStatus's setTitle:"โ„"
  255. do shell script "open -a '/Applications/Utilities/Script Editor.app' /Applications/Tools/Controller.app"
  256. try
  257. do shell script "cat /etc/hosts |grep FULL_HOSTS_BLOCK"
  258. itemStatus's setTitle:"๐Ÿšฆ"
  259. on error
  260. itemStatus's setTitle:"๐Ÿ”“"
  261. end try
  262.  
  263. else if menuTitle is equal to "โœ Dozer R/W" then
  264. itemStatus's setTitle:"โœ"
  265. do shell script "mkdir /Users/aegon/Desktop/DozerOFF &> /dev/null &"
  266. do shell script "sudo mount -t ntfs -o rw,auto,nobrowse /dev/disk0s4 /Users/aegon/Desktop/DozerOFF" with administrator privileges
  267. try
  268. do shell script "cat /etc/hosts |grep FULL_HOSTS_BLOCK"
  269. itemStatus's setTitle:"๐Ÿšฆ"
  270. on error
  271. itemStatus's setTitle:"๐Ÿ”“"
  272. end try
  273.  
  274. else if menuTitle is equal to "โœ’ Dozer Read Only" then
  275. itemStatus's setTitle:"โœ’"
  276. do shell script "diskutil mount /dev/disk0s4"
  277. try
  278. do shell script "cat /etc/hosts |grep FULL_HOSTS_BLOCK"
  279. itemStatus's setTitle:"๐Ÿšฆ"
  280. on error
  281. itemStatus's setTitle:"๐Ÿ”“"
  282. end try
  283.  
  284. else if menuTitle is equal to "โ†• Mounty" then
  285. itemStatus's setTitle:"โ†•"
  286. do shell script "open /Applications/Tools/Mounty.app"
  287. try
  288. do shell script "cat /etc/hosts |grep FULL_HOSTS_BLOCK"
  289. itemStatus's setTitle:"๐Ÿšฆ"
  290. on error
  291. itemStatus's setTitle:"๐Ÿ”“"
  292. end try
  293.  
  294. else if menuTitle is equal to "โ„น Show/Hide Files" then
  295. itemStatus's setTitle:"โ„น"
  296. set visibility to (do shell script "defaults read com.apple.finder AppleShowAllFiles")
  297. if visibility is "1" then
  298. do shell script "defaults write com.apple.finder AppleShowAllFiles 0"
  299. set resetFinder to display dialog "Restarting Finder in 3 seconds" buttons {"Cancel"} default button "Cancel" with icon stop giving up after 3
  300. tell application "Finder" to quit
  301. delay 1
  302. tell application "Finder" to activate
  303. else if visibility is "0" then
  304. do shell script "defaults write com.apple.finder AppleShowAllFiles 1"
  305. set resetFinder to display dialog "Restarting Finder in 3 seconds" buttons {"Cancel"} default button "Cancel" with icon stop giving up after 3
  306. tell application "Finder" to quit
  307. delay 1
  308. tell application "Finder" to activate
  309. end if
  310. try
  311. do shell script "cat /etc/hosts |grep FULL_HOSTS_BLOCK"
  312. itemStatus's setTitle:"๐Ÿšฆ"
  313. on error
  314. itemStatus's setTitle:"๐Ÿ”“"
  315. end try
  316.  
  317. end if
  318. end actionHandler:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement