Myself-bbs.com HTML5 Player

HTML5 Player for 云端

当前为 2016-09-24 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Myself-bbs.com HTML5 Player
  3. // @namespace http://myself-bbs.com/
  4. // @version 0.4
  5. // @description HTML5 Player for 云端
  6. // @author Deloz
  7. // @match http://*.myself-bbs.com/*
  8. // @match http://myself-bbs.com/*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function($) {
  13. 'use strict';
  14. var getUrlVars = function(url){
  15. var vars = [], hash;
  16. var hashes = url.slice(url.indexOf('?') + 1).split('&');
  17. for(var i = 0; i < hashes.length; i++)
  18. {
  19. hash = hashes[i].split('=');
  20. vars.push(hash[0]);
  21. vars[hash[0]] = hash[1];
  22. }
  23. return vars;
  24. };
  25. var getUrlVar = function(url, name){
  26. return getUrlVars(url)[name];
  27. };
  28.  
  29. $('.various.google').click(function(e) {
  30. e.preventDefault();
  31. var self = $(this);
  32. var url = self.data('href');
  33. var docId = getUrlVar(url, 'docid');
  34. var videoUrl = (docId === undefined ? url.replace('/preview', '/view') : 'https://docs.google.com/file/d/'+docId+'/view');
  35. window.open(videoUrl, '_blank');
  36. });
  37. })(jQuery);