Idle Pixel Friend Request

Alerts when receiving a friend request

  1. // ==UserScript==
  2. // @name Idle Pixel Friend Request
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0.0
  5. // @description Alerts when receiving a friend request
  6. // @author Felipe Dounford
  7. // @require https://gf.qytechs.cn/scripts/441206-idlepixel/code/IdlePixel+.js
  8. // @match *://idle-pixel.com/login/play*
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=gf.qytechs.cn
  10. // @grant none
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. class FriendRequestPlugin extends IdlePixelPlusPlugin {
  18. constructor() {
  19. super("friendRequest", {
  20. about: {
  21. name: GM_info.script.name + " (ver: " + GM_info.script.version + ")",
  22. version: GM_info.script.version,
  23. author: GM_info.script.author,
  24. description: GM_info.script.description
  25. }
  26. });
  27. }
  28.  
  29. onLogin() {
  30. IdlePixelPlus.plugins.friendRequest.changeaddFriendFunction()
  31. IdlePixelPlus.plugins.friendRequest.addUI()
  32. }
  33.  
  34. addUI() {
  35. let FRDiv = document.createElement('div');
  36. FRDiv.id = "friendRequest"
  37. FRDiv.style.cssText = "border: 2px solid rgb(0, 0, 77);padding: 10px;z-index: 10;position: absolute;top: 100px;left: 0px;margin-right: auto;margin-left: auto;width: 30%;background-color: rgb(230, 230, 255);border-radius: 10px;text-align: center;display: none;height: auto;right: 0px;"
  38. FRDiv.innerHTML = `<div class="modal-header">
  39. <h5 class="modal-title text-secondary">Friend Request</h5>
  40. <button type="button" class="btn-close" onclick="this.parentNode.parentNode.style.display = 'none'"></button><input type="text" id="friendRequestName" style="display:none;">
  41. </div>
  42. <div>
  43. <center><b><span id="friendRequestFriend">Player</span></b> wants to be your friend.
  44. <br>
  45. </center>
  46. </div>
  47. <div class="modal-footer">
  48. <button onclick="this.parentNode.parentNode.style.display = 'none'"><span class="font-pixel hover">Ignore</span></button>
  49. <button class="background-primary float-end" onclick="IdlePixelPlus.plugins.friendRequest.acceptFR()"><span class="font-pixel hover">Accept Friend Request</span></button>
  50. </div>`
  51. document.getElementById('content').appendChild(FRDiv)
  52. }
  53.  
  54. changeaddFriendFunction() {
  55. //Change Chat Class to call the request function
  56. Chat.add_friend_modal_submit = function() {
  57. var value = document.getElementById("modal-add-friend-input").value;
  58. websocket.send('ADD_FRIEND=' + value);
  59. IdlePixelPlus.plugins.friendRequest.sendFR(value)
  60. }
  61. }
  62.  
  63. onCustomMessageReceived(player, content, callbackId) {
  64. if(content.startsWith("friendRequest")) {
  65. this.receiveFR(player);
  66. }
  67. }
  68. sendFR(username) {
  69. IdlePixelPlus.sendCustomMessage(username, {
  70. content: `friendRequest`,
  71. timout: 300000
  72. });
  73. }
  74. receiveFR(username) {
  75. document.getElementById('friendRequestName').value = username
  76. document.getElementById('friendRequestFriend').innerText = username
  77. document.getElementById('friendRequest').style.display = ''
  78. }
  79. acceptFR() {
  80. document.getElementById('friendRequest').style.display = 'none'
  81. let friend = document.getElementById('friendRequestName').value
  82. websocket.send('ADD_FRIEND=' + friend);
  83. }
  84. }
  85.  
  86. const plugin = new FriendRequestPlugin();
  87. IdlePixelPlus.registerPlugin(plugin);
  88.  
  89. })();

QingJ © 2025

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