Plugins for capturing URLs

Send the URL to your remote server to build your own benign dataset

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Plugins for capturing URLs
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Send the URL to your remote server to build your own benign dataset
// @author       pic4xiu
// @icon         https://cdn2.iconfinder.com/data/icons/artificial-intelligence-6/64/ArtificialIntelligence6-512.png
// @match        *://*/*
// @grant        GM_xmlhttpRequest
// @license      MIT
// ==/UserScript==

(function() {
  'use strict';

  // Get the URL of the current page
  const currentUrl = window.location.href;

  // Send HTTP request to send URL to server
  GM_xmlhttpRequest({
    method: 'POST',
    url: 'http://***:7000',//Change it to your own. I use Alibaba Cloud. It's easy to use. Go to Alibaba Cloud when you go to the cloud! 
    data: currentUrl,//Of course, if you want to be more secure, you can change it to https
    headers: {
      'Content-Type': 'text/plain'
    },
    onload: function(response) {
      console.log('URL sent to server');
    },
    onerror: function(error) {
      console.error('Error sending URL to server:', error);
    }
  });
})();

/*
//The server receives the URL and writes it to the urls.txt file. This is a demonstration of nodejs
const http = require('http');
const fs = require('fs');

const server = http.createServer((req, res) => {
  if (req.method === 'POST') {
    let body = '';
    req.on('data', chunk => {
      body += chunk.toString();
    });
    req.on('end', () => {
      fs.appendFile('urls.txt', body + '\n', err => {
        if (err) {
          console.error('Error appending URL to file:', err);
          res.statusCode = 500;
          res.end('Error appending URL to file');
        } else {
          console.log('URL appended to file:', body);
          res.statusCode = 200;
          res.end('URL appended to file');
        }
      });
    });
  } else {
    res.statusCode = 404;
    res.end('Not found');
  }
});

server.listen(7000, () => {
  console.log('Server running on port 7000');
*/