InstaSynchP Library

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

目前为 2014-10-13 提交的版本。查看 最新版本

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.gf.qytechs.cn/scripts/5647/21149/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.3
  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. if (!window.pluginLibrary) {
  20. if (typeof String.prototype.startsWith !== 'function') {
  21. // see below for better implementation!
  22. String.prototype.startsWith = function (str) {
  23. return this.indexOf(str) === 0;
  24. };
  25. }
  26.  
  27. window.isBlackname = function (username) {
  28. "use strict";
  29. if (typeof username !== 'string') {
  30. return false;
  31. }
  32. return username.match(/^([A-Za-z0-9]|([\-_](?![\-_]))){5,16}$/) !== null;
  33. };
  34.  
  35. window.activeVideoIndex = function () {
  36. "use strict";
  37. return $('#playlist .active').index();
  38. };
  39.  
  40. window.findUserId = function (id) {
  41. "use strict";
  42. var i;
  43. for (i = 0; i < window.users.length; i += 1) {
  44. if (id === window.users[i].id) {
  45. return window.users[i];
  46. }
  47. }
  48. return undefined;
  49. };
  50. window.findUserName = function (name) {
  51. "use strict";
  52. var i;
  53. for (i = 0; i < window.users.length; i += 1) {
  54. if (name === window.users[i].name) {
  55. return window.users[i];
  56. }
  57. }
  58. return undefined;
  59. };
  60.  
  61. window.videojs = function () {
  62. "use strict";
  63. return $('.video-js')[0];
  64. };
  65.  
  66. window.reloadPlayer = function () {
  67. "use strict";
  68. if (window.video) {
  69. window.video.destroy();
  70. }
  71. window.global.sendcmd('reload', null);
  72. };
  73.  
  74. window.addSystemMessage = function (message) {
  75. "use strict";
  76. window.addMessage({
  77. username: ""
  78. }, message, 'system');
  79. };
  80.  
  81. window.addErrorMessage = function (message) {
  82. "use strict";
  83. window.addMessage({
  84. username: ""
  85. }, message, 'errortext');
  86. };
  87.  
  88. window.videoInfoEquals = function (a, b) {
  89. "use strict";
  90. if (!a || !b) {
  91. return false;
  92. }
  93. if (a.provider && a.provider === b.provider &&
  94. a.mediaType && a.mediaType === b.mediaType &&
  95. a.id && a.id === b.id) {
  96. return true;
  97. }
  98. return false;
  99. };
  100. window.pluginLibrary = true;
  101. }

QingJ © 2025

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