קוד:
window.onkeydown = function(e) {
// CTRL + SHIFT + 1 :: NEXT SONG
if(e.ctrlKey && e.shiftKey && e.keyCode == 49){
if($(".next-playlist-list-item").length == 1){
window.location = $(".next-playlist-list-item").attr('href');
}
}
// CTRL + SHIFT + 2 :: PREV SONG
if(e.ctrlKey && e.shiftKey && e.keyCode == 50){
if($(".prev-playlist-list-item").length == 1){
window.location = $(".prev-playlist-list-item").attr('href');
}
}
}
קוד:
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
Media_Next::
IfWinNotExist ahk_class MozillaWindowClass
return
SendToFirefox(1)
return
Media_Prev::
IfWinNotExist ahk_class MozillaWindowClass
return
SendToFirefox(2)
return
SendToFirefox(KeyCode)
{
WaitForTabChange = 200
SetTitleMatchMode, 2
; Loop through all Firefox windows.
WinGet, id, list, Firefox, , Program Manager
Loop, %id%
{
StringTrimRight, this_id, id%a_index%, 0
WinGetTitle, StartingTitle , ahk_id %this_id%
; Loop through all tabs.
loop
{
ControlSend,ahk_parent,{Ctrl Down}{Shift Down}%KeyCode%{Ctrl Up}{Shift Up},ahk_id %this_id%
Sleep 100
ControlSend,ahk_parent,{Control down}{Tab}{Control Up},ahk_id %this_id%
Sleep WaitForTabChange
WinGetTitle, CurrentTabTitle , ahk_id %this_id%
If (CurrentTabTitle == StartingTitle){
break
}
}
}
}