linuxdo-next

一个呼吸顺畅的 linux.do 论坛

目前为 2024-03-09 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name linuxdo-next
  3. // @namespace linuxdo-next
  4. // @version 0.1.0
  5. // @author delph1s
  6. // @description 一个呼吸顺畅的 linux.do 论坛
  7. // @license GPLv2
  8. // @iconURL https://cdn.linux.do/uploads/default/original/1X/3a18b4b0da3e8cf96f7eea15241c3d251f28a39b.png
  9. // @match *://linux.do/
  10. // @match *://linux.do/*
  11. // @require https://cdn.jsdelivr.net/npm/react@18.2.0/umd/react.production.min.js
  12. // @require https://cdn.jsdelivr.net/npm/react-dom@18.2.0/umd/react-dom.production.min.js
  13. // @grant GM_addStyle
  14. // @run-at document-end
  15. // ==/UserScript==
  16.  
  17. (t=>{if(typeof GM_addStyle=="function"){GM_addStyle(t);return}const n=document.createElement("style");n.textContent=t,document.head.append(n)})(' :export{appName:"linuxdo-next";pluginContainer:linuxdo-next-container;functionButton:linuxdo-next-function-button}#linuxdo-next-container{width:100%;height:100%;position:absolute;top:0;left:0;z-index:-9999}.linuxdo-next-function-button{position:absolute;top:120px;right:40px;z-index:9999} ');
  18.  
  19. (function (require$$0, require$$0$1) {
  20. 'use strict';
  21.  
  22. var jsxRuntime = { exports: {} };
  23. var reactJsxRuntime_production_min = {};
  24. /**
  25. * @license React
  26. * react-jsx-runtime.production.min.js
  27. *
  28. * Copyright (c) Facebook, Inc. and its affiliates.
  29. *
  30. * This source code is licensed under the MIT license found in the
  31. * LICENSE file in the root directory of this source tree.
  32. */
  33. var f = require$$0, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m$1 = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: true, ref: true, __self: true, __source: true };
  34. function q(c, a, g) {
  35. var b, d = {}, e = null, h = null;
  36. void 0 !== g && (e = "" + g);
  37. void 0 !== a.key && (e = "" + a.key);
  38. void 0 !== a.ref && (h = a.ref);
  39. for (b in a)
  40. m$1.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
  41. if (c && c.defaultProps)
  42. for (b in a = c.defaultProps, a)
  43. void 0 === d[b] && (d[b] = a[b]);
  44. return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
  45. }
  46. reactJsxRuntime_production_min.Fragment = l;
  47. reactJsxRuntime_production_min.jsx = q;
  48. reactJsxRuntime_production_min.jsxs = q;
  49. {
  50. jsxRuntime.exports = reactJsxRuntime_production_min;
  51. }
  52. var jsxRuntimeExports = jsxRuntime.exports;
  53. var client = {};
  54. var m = require$$0$1;
  55. {
  56. client.createRoot = m.createRoot;
  57. client.hydrateRoot = m.hydrateRoot;
  58. }
  59. const appName = '"linuxdo-next"';
  60. const pluginContainer = "linuxdo-next-container";
  61. const functionButton = "linuxdo-next-function-button";
  62. const styles = {
  63. appName,
  64. pluginContainer,
  65. functionButton
  66. };
  67. function Modal(props) {
  68. return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "modal-container", children: [
  69. /* @__PURE__ */ jsxRuntimeExports.jsx(
  70. "div",
  71. {
  72. id: "ember628",
  73. className: "ember-view modal d-modal create-invite-modal",
  74. "data-keyboard": "false",
  75. "aria-modal": "true",
  76. role: "dialog",
  77. "aria-labelledby": "discourse-modal-title",
  78. children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "d-modal__container", children: [
  79. /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "d-modal__header", children: [
  80. /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "d-modal__title", children: /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { id: "discourse-modal-title", className: "d-modal__title-text", children: "创建邀请" }) }),
  81. /* @__PURE__ */ jsxRuntimeExports.jsx(
  82. "button",
  83. {
  84. className: "btn no-text btn-icon btn-transparent modal-close",
  85. title: "关闭",
  86. type: "button",
  87. onClick: () => props.setModalVisible(false),
  88. children: /* @__PURE__ */ jsxRuntimeExports.jsx(
  89. "svg",
  90. {
  91. className: "fa d-icon d-icon-times svg-icon svg-string",
  92. xmlns: "http://www.w3.org/2000/svg",
  93. children: /* @__PURE__ */ jsxRuntimeExports.jsx("use", { href: "#times" })
  94. }
  95. )
  96. }
  97. )
  98. ] }),
  99. /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "d-modal__body", tabIndex: -1, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("form", { children: [
  100. /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "input-group input-email", children: [
  101. /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { htmlFor: "invite-email", children: [
  102. /* @__PURE__ */ jsxRuntimeExports.jsx(
  103. "svg",
  104. {
  105. className: "fa d-icon d-icon-envelope svg-icon svg-string",
  106. xmlns: "http://www.w3.org/2000/svg",
  107. children: /* @__PURE__ */ jsxRuntimeExports.jsx("use", { href: "#envelope" })
  108. }
  109. ),
  110. "限制为"
  111. ] }),
  112. /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "invite-email-container", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
  113. "input",
  114. {
  115. id: "invite-email",
  116. className: "ember-text-field ember-view",
  117. placeholder: "name@example.com 或者 example.com",
  118. type: "text"
  119. }
  120. ) })
  121. ] }),
  122. /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "input-group invite-max-redemptions", children: [
  123. /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { htmlFor: "invite-max-redemptions", children: [
  124. /* @__PURE__ */ jsxRuntimeExports.jsx(
  125. "svg",
  126. {
  127. className: "fa d-icon d-icon-users svg-icon svg-string",
  128. xmlns: "http://www.w3.org/2000/svg",
  129. children: /* @__PURE__ */ jsxRuntimeExports.jsx("use", { href: "#users" })
  130. }
  131. ),
  132. "最大使用次数"
  133. ] }),
  134. /* @__PURE__ */ jsxRuntimeExports.jsx(
  135. "input",
  136. {
  137. id: "invite-max-redemptions",
  138. className: "ember-text-field ember-view",
  139. min: "1",
  140. max: "10",
  141. type: "number"
  142. }
  143. )
  144. ] }),
  145. /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "input-group input-expires-at", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { children: [
  146. /* @__PURE__ */ jsxRuntimeExports.jsx(
  147. "svg",
  148. {
  149. className: "fa d-icon d-icon-far-clock svg-icon svg-string",
  150. xmlns: "http://www.w3.org/2000/svg",
  151. children: /* @__PURE__ */ jsxRuntimeExports.jsx("use", { href: "#far-clock" })
  152. }
  153. ),
  154. "于 3 天过期"
  155. ] }) })
  156. ] }) }),
  157. /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "d-modal__footer", children: [
  158. /* @__PURE__ */ jsxRuntimeExports.jsxs("button", { className: "btn btn-icon-text btn-primary save-invite", type: "button", children: [
  159. /* @__PURE__ */ jsxRuntimeExports.jsx(
  160. "svg",
  161. {
  162. className: "fa d-icon d-icon-link svg-icon svg-string",
  163. xmlns: "http://www.w3.org/2000/svg",
  164. children: /* @__PURE__ */ jsxRuntimeExports.jsx("use", { href: "#link" })
  165. }
  166. ),
  167. /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "d-button-label", children: "保存邀请" })
  168. ] }),
  169. /* @__PURE__ */ jsxRuntimeExports.jsxs(
  170. "button",
  171. {
  172. className: "btn btn-icon-text btn-primary send-invite",
  173. disabled: false,
  174. title: "限制只允许电子邮件邀请并发送邀请电子邮件",
  175. type: "button",
  176. children: [
  177. /* @__PURE__ */ jsxRuntimeExports.jsx(
  178. "svg",
  179. {
  180. className: "fa d-icon d-icon-envelope svg-icon svg-string",
  181. xmlns: "http://www.w3.org/2000/svg",
  182. children: /* @__PURE__ */ jsxRuntimeExports.jsx("use", { href: "#envelope" })
  183. }
  184. ),
  185. /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "d-button-label", children: "保存并发送电子邮件" })
  186. ]
  187. }
  188. )
  189. ] })
  190. ] })
  191. }
  192. ),
  193. /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "d-modal__backdrop" })
  194. ] });
  195. }
  196. function App() {
  197. const [logModalVisible, setLogModalVisible] = require$$0.useState(false);
  198. require$$0.useEffect(() => {
  199. const containerSelector = "header.d-header div.contents div.panel ul";
  200. document.querySelector(containerSelector);
  201. document.createElement("li");
  202. }, []);
  203. return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: styles.functionButton, children: [
  204. /* @__PURE__ */ jsxRuntimeExports.jsx(
  205. "button",
  206. {
  207. className: "btn btn-default create reply-to-post no-text btn-icon",
  208. title: "开始进行自动点赞",
  209. type: "button",
  210. onClick: () => setLogModalVisible(true),
  211. children: /* @__PURE__ */ jsxRuntimeExports.jsx(
  212. "svg",
  213. {
  214. className: "fa d-icon d-icon-paper-plane svg-icon prefix-icon svg-string",
  215. xmlns: "http://www.w3.org/2000/svg",
  216. children: /* @__PURE__ */ jsxRuntimeExports.jsx("use", { href: "#paper-plane" })
  217. }
  218. )
  219. }
  220. ),
  221. logModalVisible && /* @__PURE__ */ jsxRuntimeExports.jsx(Modal, { setModalVisible: setLogModalVisible })
  222. ] });
  223. }
  224. const appendLinuxDoNext = () => {
  225. const app = document.createElement("div");
  226. app.setAttribute("id", styles.pluginContainer);
  227. document.body.append(app);
  228. return app;
  229. };
  230. client.createRoot(appendLinuxDoNext()).render(
  231. /* @__PURE__ */ jsxRuntimeExports.jsx(require$$0.StrictMode, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(App, {}) })
  232. );
  233.  
  234. })(React, ReactDOM);