InstaSynchP UserSpy

Log user actions into the chat (login/off, video add)

目前為 2014-11-23 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name InstaSynchP UserSpy
  3. // @namespace InstaSynchP
  4. // @description Log user actions into the chat (login/off, video add)
  5.  
  6. // @version 1
  7. // @author Zod-
  8. // @source https://github.com/Zod-/InstaSynchP-UserSpy
  9. // @license MIT
  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.  
  18. // @require https://greasyfork.org/scripts/5647-instasynchp-library/code/InstaSynchP%20Library.js
  19. // ==/UserScript==
  20. function UserSpy(version) {
  21. "use strict";
  22. this.version = version;
  23. this.name = 'InstaSynchP UserSpy';
  24. this.settings = [{
  25. 'label': 'Login/off',
  26. 'id': 'login-off-log',
  27. 'type': 'checkbox',
  28. 'default': true,
  29. 'section': ['Chat', 'UserSpy']
  30. }, {
  31. 'label': 'Rename',
  32. 'id': 'rename-log',
  33. 'type': 'checkbox',
  34. 'default': true,
  35. 'section': ['Chat', 'UserSpy']
  36. }, {
  37. 'label': 'Add video',
  38. 'id': 'add-video-log',
  39. 'type': 'checkbox',
  40. 'default': true,
  41. 'section': ['Chat', 'UserSpy']
  42. }];
  43. }
  44.  
  45. UserSpy.prototype.postConnect = function () {
  46. "use strict";
  47. var th = this;
  48. events.on(th, 'AddUser', th.userLoggedOn);
  49. events.on(th, 'RemoveUser', th.userLoggedOff);
  50. events.on(th, 'RenameUser', function (ignore1, ignore2, user) {
  51. if (gmc.get('rename-log')) {
  52. addSystemMessage('{0} renamed to {1}'.format(user.ip, user.username));
  53. }
  54. });
  55. events.on(th, 'AddVideo', th.videoAdded);
  56. };
  57. UserSpy.prototype.videoAdded = function (video) {
  58. if (!gmc.get('rename-log')) {
  59. return;
  60. }
  61. var url = urlParser.create(video.info),
  62. len = 240 + url.length,
  63. message = '{0}</a>'.format('{0} added <a href="{1}">{2}'.format(
  64. video.addedby,
  65. url,
  66. video.title).substr(0, len));
  67. addSystemMessage(message);
  68. };
  69.  
  70. UserSpy.prototype.resetVariables = function () {
  71. "use strict";
  72. var th = this;
  73. events.unbind('AddUser', th.userLoggedOn);
  74. events.unbind('RemoveUser', th.userLoggedOff);
  75. events.unbind('AddVideo', th.videoAdded);
  76. };
  77.  
  78. UserSpy.prototype.userLoggedOn = function (user) {
  79. "use strict";
  80. if (gmc.get('login-off-log')) {
  81. addSystemMessage('{0}({1}) logged on.'.format(user.username, user.ip));
  82. }
  83. };
  84.  
  85. UserSpy.prototype.userLoggedOff = function (id, user) {
  86. "use strict";
  87. if (gmc.get('login-off-log')) {
  88. addSystemMessage('{0}({1}) logged off.'.format(user.username, user.ip));
  89. }
  90. };
  91.  
  92. window.plugins = window.plugins || {};
  93. window.plugins.userSpy = new UserSpy('1');