• «
  • 1
  • 2
  • »
  • Pages: 1/2     Go

336831.jpg

nideii

又一个轮子,这次是南+的增强脚本

新版本: https://north-plus.net/read.php?tid-1206088.html


反正都写出来了,就拿出来吧。      

新增功能
---
+ 快速跳转到帖子购买处
+ 加了一个快速回到顶部的按钮
+ 提取百度秒链(虽然只处理了一种格式),方便原地改名字归类整理

虽然这个是JS,但是代码看起来像python         

复制代码
  1. // ==UserScript==
  2. // @name         South-Plus Enhancement
  3. // @namespace    http://north-plus.net/
  4. // @version      0.1
  5. // @description  South-Plus Enhancement
  6. // @author       nideii
  7. // @include      http*://north-plus.net/*
  8. // @include      http*://north-plus.net/*
  9. // @include      http*://north-plus.net/*
  10. // @include      http*://north-plus.net/*
  11. // @include      http*://north-plus.net/*
  12. // @include      http*://*.level-plus.net/*
  13. // @include      http*://*.south-plus.net/*
  14. // @include      http*://*.south-plus.org/*
  15. // @include      http*://*.white-plus.net/*
  16. // @include      http*://*.imoutolove.me/*
  17. // @require      https://cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js
  18. // @require      https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.12.0/underscore-min.js
  19. // @require      https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js
  20. // @run-at       document-idle
  21. // @grant        GM_addStyle
  22. // ==/UserScript==
  23. (function () {
  24.     'use strict';
  25.     GM_addStyle(`
  26. #topbutton {
  27.     display: inline-block;
  28.     border-radius: 3px;
  29.     color: #fff!important;
  30.     line-height: 20px;
  31.     transition: all .5s ease-in-out;
  32.     background: linear-gradient(180deg,#90a4ae,#78909c);
  33.     width: 40px;
  34.     height: 40px;
  35.     position: fixed;
  36.     right: 10px;
  37.     bottom: 40px;
  38.     z-index: 1000001;
  39.     cursor: pointer;
  40. }
  41. #topbutton:hover {
  42.     cursor: pointer;
  43.     background: linear-gradient(180deg,#78909c,#546e7a);
  44. }
  45. #topbutton.show {
  46.     opacity: 1;
  47.     visibility: visible;
  48. }
  49. #topbutton svg {
  50.     position: absolute;
  51.     left: 0;
  52.     top: 0;
  53.     right: 0;
  54.     bottom: 0;
  55.     width: 10px;
  56.     height: 10px;
  57.     margin: auto;
  58.     fill: #fff
  59. }
  60.     `);
  61.     $('body').append(`<div id="topbutton">
  62.     <svg data-markup-inline="" alt="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
  63.          version="1.1" x="0px" y="0px" width="349.629px" height="349.629px" viewBox="0 0 349.629 349.629"
  64.          xml:space="preserve">
  65.         <polygon
  66.                 points="174.827,73.433 0,253.42 23.434,276.19 174.827,120.318 326.216,276.196 349.629,253.42   ">
  67.         </polygon>
  68.      </svg>
  69.     </div>`);
  70.     let topbtn = $('#topbutton');
  71.     $(window).scroll(() => $(window).scrollTop() > 300 ? topbtn.show() : topbtn.hide());
  72.     topbtn.click(() => $('html, body').animate({ scrollTop: 0 }, '300'));
  73.     let buyers_list = $('select[name="buyers"]');
  74.     let quote_info = $('h6.quote.jumbotron > span.s3');
  75.     if (buyers_list.length == 0) {
  76.         return;
  77.     }
  78.     if (buyers_list.length != quote_info.length) {
  79.         console.error('buyers_list.length != quote_info.length');
  80.         return;
  81.     }
  82.     const thread_title = '\n' + $($('h1#subject_tpc')[0]).text() + '\n';
  83.     let rapid = 1;
  84.     for (let block of $('blockquote.blockquote.jumbotron')) {
  85.         let links = [];
  86.         let rows = 0;
  87.         const text = block.innerText;
  88.         const lines = text.split('\n');
  89.         for (const [i, line] of lines.entries()) {
  90.             let m = line.match(/([A-Fa-f0-9]{32}#[A-Fa-f0-9]{32}#[0-9]+#)(.*)/);
  91.             if (m == null || m.length != 3) {
  92.                 continue;
  93.             }
  94.             links.push([m[1], m[2]]);
  95.         }
  96.         if (links.length == 0) {
  97.             continue;
  98.         }
  99.         let link_text = '';
  100.         for (const [i, [finfo, fname]] of links.entries()) {
  101.             link_text += `${finfo}\n{prefix}\n${fname}\n`;
  102.             rows += 3;
  103.             if (i != links.length - 1) {
  104.                 link_text += '---\n';
  105.                 rows += 1;
  106.             }
  107.         }
  108.         rows = rows > 10 ? 12 : rows + 2;
  109.         $(`<button type="button" class="bdrapid-btn" data-rapid="${rapid}"
  110.             style="border: 1px solid #dddddd; margin-bottom: 2px;">复制秒链</button>`).insertBefore(block);
  111.         $(`<button type="button" class="bdrapid-clear-btn" data-rapid="${rapid}"
  112.             style="border: 1px solid #dddddd; margin: 0 0 2px 2px;">清空前缀</button><br>`).insertBefore(block);
  113.         $(`<textarea id="bdrapid-prefix-${rapid}" style="width:85%" rows="3"></textarea>`).insertBefore(block).val(thread_title);
  114.         $(`<textarea id="bdrapid-${rapid}" style="width:85%" rows="${rows}">${link_text}</textarea>`).insertBefore(block);
  115.         rapid += 1;
  116.     }
  117.     const num_quote = buyers_list.length;
  118.     const li_style_1 = ' style="cursor: pointer;"';
  119.     const li_style_2 = ' style="cursor: pointer;border-left:1px solid #eeeeee;"';
  120.     let jump_list = '';
  121.     for (let [i, [attach, info]] of _.zip(buyers_list, quote_info).entries()) {
  122.         let purchased = false;
  123.         for (const cls of info.classList) {
  124.             if (cls == 'f12' || cls == 'fn') {
  125.                 purchased = true;
  126.                 break;
  127.             }
  128.         }
  129.         let sp = $(info).text().match(/此帖售价 ([0-9]+) SP币,已有 [0-9]+ 人购买/)[1];
  130.         sp = `  - ${sp} SP`;
  131.         let reply = attach.closest('div.t5.t2');
  132.         let floor_id = $('div.tiptop > span.fl > a.s3', reply)[0].text.trim();
  133.         // let reply_title = $('div.h1.fl > h1.fl', reply).text();
  134.         // $(`<blockquote class="blockquote jumbotron replytitle">
  135.         //     ${reply_title}
  136.         //     </blockquote>`)
  137.         //     .insertAfter($(info).parent()[0]);
  138.         jump_list += `
  139.         <li${i == 0 ? li_style_1 : li_style_2}>
  140.         <a class="fn jump_quote" quote-id="${i}">
  141.             <input type="checkbox" ${purchased ? 'checked' : ''} disabled ${li_style_1}>
  142.             <label ${li_style_1}>
  143.             ${floor_id}${num_quote > 3 ? '' : sp}
  144.             </label>
  145.         </a>
  146.         </li>`;
  147.     }
  148.     $(`<span class="fl pages"><ul>${jump_list}</ul></span>`).insertBefore('div.t3 > div.c');
  149.     $('a.jump_quote[quote-id]').click(function () {
  150.         let id = parseInt($(this).attr('quote-id'));
  151.         if (id != id || id < 0 || id > buyers_list.length) {
  152.             return;
  153.         }
  154.         buyers_list[id].scrollIntoView(
  155.             { behavior: "auto", block: "center", inline: "nearest" }
  156.         );
  157.     });
  158.     $('button.bdrapid-clear-btn').click(function () {
  159.         const rapid = $(this).attr('data-rapid');
  160.         $(`textarea#bdrapid-prefix-${rapid}`).val('');
  161.     });
  162.     function safe_path(str) {
  163.         var dict = {
  164.             '<': '<',
  165.             '>': '>',
  166.             ':': ':',
  167.             '"': '”',
  168.             ':': ':',
  169.             '/': '/',
  170.             '\\': '\',
  171.             '|': '|',
  172.             '?': '?',
  173.             '*': '*',
  174.         };
  175.     
  176.         for (let k in dict) {
  177.             str = str.replace(k, dict[k]);
  178.         }
  179.         return str;
  180.     }
  181.     new ClipboardJS('.bdrapid-btn', {
  182.         text: function (trigger) {
  183.             const rapid = $(trigger).attr('data-rapid');
  184.             const prefix_val = $(`textarea#bdrapid-prefix-${rapid}`).val();
  185.             let prefix = '';
  186.             for (const [i, line] of prefix_val.split('\n').entries()) {
  187.                 if (line.length > 0) {
  188.                     prefix += safe_path(line) + '/';
  189.                 }
  190.             }
  191.             prefix = prefix.substr(0, prefix.length - 1);
  192.             const link_text = $(`textarea#bdrapid-${rapid}`).val();
  193.             let rapid_links = '';
  194.             for (let line of link_text.split('\n')) {
  195.                 if (line == '---') {
  196.                     rapid_links += '\n';
  197.                     continue;
  198.                 }
  199.                 if (line == '{prefix}') {
  200.                     line = prefix;
  201.                     if (line.length > 0) {
  202.                         line += '/';
  203.                     }
  204.                 }
  205.                 rapid_links += line;
  206.             }
  207.             console.log(rapid_links);
  208.             return rapid_links;
  209.         }
  210.     });
  211. })();


大体上这里给一个测试内容
此帖售价 0 SP币,已有 216 人购买
若发现会员采用欺骗的方法获取财富,请立刻举报,我们会对会员处以2-N倍的罚金,严重者封掉ID!

336831.jpg

nideii

此帖售价 0 SP币,已有 148 人购买
若发现会员采用欺骗的方法获取财富,请立刻举报,我们会对会员处以2-N倍的罚金,严重者封掉ID!

e22738a104deed581b389e214964ef61.jpg

老七

技术大佬

H3EwlJ1j8zmgsxB.gif

火芽&水蕓

B3F  2021-03-22 22:53
(喜欢妈妈和大姐姐!是个百合厨!特别厨母女百合!但都仅限二次w)
好怪哦...我点复制代码没用,手动复制进油猴一堆错误

空灵雨季

B4F  2021-03-22 22:54
    

888351.jpg

做到一半

B5F  2021-03-22 22:59
(。)(。)
好,支持

676223.jpg

龙哥

B6F  2021-03-22 23:06
(人类就是这样,自以为自己知道了什么,就否定了自己不知道的东 ..)
技术大佬

死灵


384240.jpg

蛋塞爱莉希雅里

B8F  2021-03-22 23:07
(用甘油干我的朋友)
请问怎么用啊   

a5.gif

润之·毛

B9F  2021-03-22 23:08
(岂因祸福避趋之)
不会用···

7f066a9e


12io592.jpg

印~痕

咱普通人,不会用啊

42132.jpg

panda

什么鬼   

619963.jpg

萌幽

试了下感觉刷新变卡了一些不知道为啥,可能我的错觉吧
我找了3分钟才找到直接跳转购买按钮
谢谢大佬分享了

619963.jpg

萌幽

我一开始以为是我梯子不稳定
关开脚本试了几次后
开新页面会比不开脚本慢。
开没购买链接的比有购买链接的更慢一些
也有可能我太小白了是我个人问题

none.gif

8b5cf2a9

这种简化操作的脚本不错

17a2f500


1394275.jpg

大大大大咸鱼

好家伙,这个咋用啊

2.gif

Aksara

B18F  2021-03-23 00:47
(算了)
油猴里添加新脚本 复制进去 文件保存就行了

非常实用 感谢大佬

1036508.png

musuhi

B19F  2021-03-23 01:25
(一阵挊就“贤者”)
啊这

783106.png

dzfAdf

我说脚本咋没生效呢,原来是你漏掉了夏+

203816.png

二次元杰杰

谢谢楼主

none.gif

skypc

不错,返回顶端比自带的方便多了。

none.gif

llx爱黑长直

回 1楼(nideii) 的帖子

不会用啥时候出个教学啊

none.gif

光明圣闲

真是小色站各种造轮子大佬

911406.jpg

puup

赞! 返回顶部太好永乐

none.gif

扣1送地狱火

用户被禁言,该主题自动屏蔽!

8


1256899.jpg

狗几把

这代码看着确实不太像js 你得压缩下 整成一行这样就像了

91919

回 楼主(nideii) 的帖子


1387764.jpg

kk?

技术大佬np
  • «
  • 1
  • 2
  • »
  • Pages: 1/2     Go