InstaSynchP Library

Basic function that are needed by several scripts use with @require

当前为 2014-10-13 提交的版本,查看 最新版本

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.gf.qytechs.cn/scripts/5647/21124/InstaSynchP%20Library.js

  1. // ==UserScript==
  2. // @name InstaSynchP Library
  3. // @namespace InstaSynchP
  4. // @description Basic function that are needed by several scripts use with @require
  5.  
  6. // @version 1.0.2
  7. // @author Zod-
  8. // @source https://github.com/Zod-/InstaSynchP-Library
  9. // @license GPL-3.0
  10.  
  11. // @include http://*.instasynch.com/*
  12. // @include http://instasynch.com/*
  13. // @include http://*.instasync.com/*
  14. // @include http://instasync.com/*
  15. // @grant none
  16. // @run-at document-start
  17. // ==/UserScript==
  18.  
  19. //parent class for all plugins
  20. function Plugin(version){
  21. this.version = version;
  22. }
  23.  
  24. if (!window.pluginLibrary) {
  25. if (typeof String.prototype.startsWith !== 'function') {
  26. // see below for better implementation!
  27. String.prototype.startsWith = function (str) {
  28. return this.indexOf(str) === 0;
  29. };
  30. }
  31.  
  32. window.isBlackname = function (username) {
  33. "use strict";
  34. if (typeof username !== 'string') {
  35. return false;
  36. }
  37. return username.match(/^([A-Za-z0-9]|([\-_](?![\-_]))){5,16}$/) !== null;
  38. };
  39.  
  40. window.activeVideoIndex = function () {
  41. "use strict";
  42. return $('#playlist .active').index();
  43. };
  44.  
  45. window.findUserId = function (id) {
  46. "use strict";
  47. var i;
  48. for (i = 0; i < window.users.length; i += 1) {
  49. if (id === window.users[i].id) {
  50. return window.users[i];
  51. }
  52. }
  53. return undefined;
  54. };
  55. window.findUserName = function (name) {
  56. "use strict";
  57. var i;
  58. for (i = 0; i < window.users.length; i += 1) {
  59. if (name === window.users[i].name) {
  60. return window.users[i];
  61. }
  62. }
  63. return undefined;
  64. };
  65.  
  66. window.videojs = function () {
  67. "use strict";
  68. return $('.video-js')[0];
  69. };
  70.  
  71. window.reloadPlayer = function () {
  72. "use strict";
  73. if (window.video) {
  74. window.video.destroy();
  75. }
  76. window.global.sendcmd('reload', null);
  77. };
  78.  
  79. window.addSystemMessage = function (message) {
  80. "use strict";
  81. window.addMessage({
  82. username: ""
  83. }, message, 'system');
  84. };
  85.  
  86. window.addErrorMessage = function (message) {
  87. "use strict";
  88. window.addMessage({
  89. username: ""
  90. }, message, 'errortext');
  91. };
  92.  
  93. window.videoInfoEquals = function (a, b) {
  94. "use strict";
  95. if (!a || !b) {
  96. return false;
  97. }
  98. if (a.provider && a.provider === b.provider &&
  99. a.mediaType && a.mediaType === b.mediaType &&
  100. a.id && a.id === b.id) {
  101. return true;
  102. }
  103. return false;
  104. };
  105. window.pluginLibrary = true;
  106. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址