User:PetraMagna/story.js

From Blue Archive Wiki
Revision as of 19:26, 7 January 2024 by PetraMagna (talk | contribs) (add bgm stop functionality)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
const story_js = function() {
    // wait for jQuery to become available
    function defer(method) {
        if (window.jQuery) {
            method();
        } else {
            setTimeout(function() { defer(method) }, 50);
        }
    }
    
    // specifies what to do after the user clicks on a sensei reply option
    function bgm_stop_click() {
        $('.story-bgm-container button.vjs-playing').each(function(num, pause_button) {
			pause_button.click();
        });
        
    }
    
    function bgm_init() {
        $(".story-bgm-stop-button").each(function(i, stop_button) {
        	stop_button.onclick = bgm_stop_click;
        });
    }
    
    function bgm_main() {
        $(document).ready(function() {
            bgm_init();
        });
    }
    
    defer(bgm_main);
};

story_js();