url2ss

解析独秀ssid

  1. // ==UserScript==
  2. // @name url2ss
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description 解析独秀ssid
  6. // @author You
  7. // @include http://*.fazz.ntszzy.org:8070/*
  8. // @include https://*.duxiu.com/*
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=ntszzy.org
  10. // @grant none
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16. let hoverEle;
  17. document.addEventListener('mousemove', e=>{
  18. hoverEle = document.elementFromPoint(e.clientX, e.clientY)
  19. }
  20. , {
  21. passive: true
  22. })
  23.  
  24. var clipboard = {
  25. data: '',
  26. intercept: false,
  27. hook: function(evt) {
  28. if (clipboard.intercept) {
  29. evt.preventDefault();
  30. evt.clipboardData.setData('text/plain', clipboard.data);
  31. alert(clipboard.data + ' copy success');
  32. clipboard.intercept = false;
  33. clipboard.data = '';
  34. }
  35. }
  36. };
  37.  
  38. window.addEventListener('copy', clipboard.hook);
  39.  
  40. function copy(textContent) {
  41. clipboard.data = textContent;
  42.  
  43. if (window.clipboardData) {
  44. window.clipboardData.setData('Text', clipboard.data);
  45. } else {
  46. clipboard.intercept = true;
  47. document.execCommand('copy');
  48. }
  49. }
  50.  
  51. document.addEventListener('keypress', function(e) {
  52. console.log(e);
  53. if (e.keyCode === 99) {
  54. const url = document.location.href + hoverEle.closest("a").getAttribute('href')
  55. console.log(url);
  56. const ss = new URL(url).searchParams.get('qwkey').substr(0, 8);
  57. console.log(ss);
  58. copy(ss)
  59. }
  60. })
  61. // Your code here...
  62. }
  63. )();