Table of Contents
1. Introduction to script functions
2. Installation and usage script
3. Related downloads
4. Script Preview
5. Things to note
Home Web Front-end JS Tutorial Use Greasemonkey script to collect website member information locally_javascript skills

Use Greasemonkey script to collect website member information locally_javascript skills

May 16, 2016 pm 06:43 PM

1. Introduction to script functions

Under normal circumstances, if you like a member through photos on the member search results page (the so-called member with good eyesight), it is not easy to quickly record the member’s information. Right-click on the photo, and then write down the member's homepage address. If there are more promising members who want to save a page, you have to repeat the above operation. The default search results page displays as shown below:

After installing the Greasemonkey script I wrote, the search results page will change a little. The "Write to me" button will become a "Favorite" checkbox. The effect is as shown below. Pay attention to the changes in the red box logo and the previous picture. Comparison:

Now suppose you want to collect the information of the two beauties on the right side of the first row, you click the "Collect" checkbox (if you don't want to collect it, just click again to deselect it), so that in the text box at the footer page turning position The HTML of the member information you selected will be generated, and it will be selected by default. You can right-click to copy it, as shown below:

Finally, paste the copied HTML code into the specified position of a predefined style html page (for example, paste the copied LI tag code between the UL tags of the jiayuan.html file, and then new collections will be added to the back. , the last jiayuan.html file is the record file of your favorite members), the result is as follows:

The code for the jiayuan.html template file is as follows. Copy it and save it as a file with the html suffix using Notepad.

Copy code The code is as follows:

.org/1999/xhtml">


< title>Jiayuan Member Collection






< /body>



2. Installation and usage script

To use this script function, you must install the Firefox browser , and this browser has the Greasemonkey plug-in , then you can find the JiaYuan.user.js script file locally or on the network (it is the Greasemonkey script I wrote, the code will be provided later), and then pull this JS script locally to the browser window, or access this JS through the network address Script (JiaYuan.user.js), the script installation interface will pop up, as shown below:

After successfully installing the browser, plug-in, and script, visit Jiayuan.com member search form page: http://search.jiayuan.com,
Submit a search Request, on the result page that comes out, if it is not in photo display mode, switch it over and make sure that the search results page you see is the same as the interface provided at the beginning of this article. If nothing goes wrong, you can see the "Collection" check box. Frame, please refer to "Introduction to Script Functions" for the next operation.

Warm reminder: If you want to know whether the Greasemonkey plug-in is successfully installed, please check whether the browser [Tools] has the [Greasemonkey] option, and whether there is a "little monkey" icon on the right side of the browsing status bar, and this The "little monkey" icon is not gray. If both are there, it means the Greasemonkey plug-in is successfully installed, as shown below:

(1)Firefox browser: (This version has integrated the Greasemonkey plug-in)

(2) Greasemonkey plug-in: http://releases.mozilla.org/pub/mozilla.org/addons/748/greasemonkey-0.8.20080609.0-fx.xpi (Visit and install)

(3) Save Jiayuan member information script: http://snsapps.googlecode.com/svn/trunk/JiaYuan.user.js(Visit and install)

4. Script Preview

Greasemonkey scripts are all written in JavaScript language. To write an excellent Greasemonkey application, you must be familiar with JavaScript programming, understand JavaScript DOM programming, and be able to analyze HTML code structure. If you want to know more about Greasemonkey, please read "Greasemonkey in a Simple Language" . I will publish the application script code below, hoping that it will be helpful to everyone.

Copy code The code is as follows:

// ==UserScript==
// @name Save member information
// @namespace http://www.ucoolweb.com
// @description Collect Century Jiayuan Dating Select your favorite member information from the member search results page and save them as local HTML files for easy reference in the future.
// @include http://search.jiayuan.com/result.php*m=1*
// ==/UserScript==
/**
* Define a class
*/
function clsJiaYuan()
{
/**
* Define getElementById shortcut
* @param {String} objId DOM ID
* @return {DOM}
*/
var $ = function(objId)
{
return document.getElementById(objId);
}
/**
* Define getElementsByTagName shortcut
* @param {String} tagName tag name
* @return {Array} DOM Array
*/
var $$ = function(tagName)
{
return document.getElementsByTagName(tagName);
}
/*
if (window .HTMLElement)
{
HTMLElement.prototype.$=$;
HTMLElement.prototype.$$=$$;
}
*/
/**
* Find DOM objects by style name
* @param {String} className The style name to be found, that is, the class attribute value of the tag
* @param {String} tagName Filter tag name, optional parameter, Used to narrow the search scope
* @return {Array} DOM Array
* /
var getElementsByClassName = function(className, tagName)
{
var selector = tagName || '*';
var allDom = $$(selector);
var domList = [] ;
for (var i in allDom)
{
if (allDom[i].className == className)
{
domList[domList.length] = allDom[i];
}
}
return domList;
}
/**
* Create checkboxes under each member’s avatar
*/
var createCheckBox = function()
{
var photoBoxs = getElementsByClassName(' searh_photobox', 'div');
for (var a in photoBoxs)
{
var infoList = photoBoxs[a].getElementsByTagName('a');
//Extract member information
var url = infoList[0].href;
var face = infoList[0].getElementsByTagName('img')[0].src;
var name = infoList[0].getElementsByTagName('img' )[0].alt;
//Processing advanced member information HTML
if (infoList.length == 4)
{
var about = infoList[2].innerHTML;
}
else
{
var about = infoList[3].innerHTML;
}
//Insert checkbox HTML
photoBoxs[a].getElementsByTagName('li')[ 3].innerHTML = '

5. Things to note

1. When installing the Greasemonkey plug-in to the Firefox browser, please choose to install the Greasemonkey plug-in corresponding to the browser version. It is recommended to download the "enhanced portable version" of the Firefox browser. This version generally integrates the Greasemonkey plug-in. Download reference link: http://www.jb51.net/softs/21957.html

2. The script provided in this article may become invalid with the revision of Jiayuan.com, because the Greasemonkey script is based on the HTML operation of the target website. If you find that the script is invalid, please leave me a message in time and let me correct it. Of course, if you can also write scripts, you can also modify it yourself. For modification methods, you can refer here to modify user scripts: http://www.firefox.net.cn/dig/helloworld/editing.html

3. It is understood that many browsers now support Greasemonkey, such as Chrome, Opera, and even IE. This script has not been tested on these browsers. If you find If there are problems with the script in other browser platforms, you can also leave a message to tell me.

4. You must ensure that the Greasemonkey plug-in is activated, that is, the "little monkey" icon in the lower right corner of the browser is not gray, otherwise you will not get the expected results even if you install the plug-in.
Author: WebFlash
Source: http://webflash.cnblogs.com

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How do I create and publish my own JavaScript libraries? How do I create and publish my own JavaScript libraries? Mar 18, 2025 pm 03:12 PM

Article discusses creating, publishing, and maintaining JavaScript libraries, focusing on planning, development, testing, documentation, and promotion strategies.

How do I optimize JavaScript code for performance in the browser? How do I optimize JavaScript code for performance in the browser? Mar 18, 2025 pm 03:14 PM

The article discusses strategies for optimizing JavaScript performance in browsers, focusing on reducing execution time and minimizing impact on page load speed.

What should I do if I encounter garbled code printing for front-end thermal paper receipts? What should I do if I encounter garbled code printing for front-end thermal paper receipts? Apr 04, 2025 pm 02:42 PM

Frequently Asked Questions and Solutions for Front-end Thermal Paper Ticket Printing In Front-end Development, Ticket Printing is a common requirement. However, many developers are implementing...

How do I debug JavaScript code effectively using browser developer tools? How do I debug JavaScript code effectively using browser developer tools? Mar 18, 2025 pm 03:16 PM

The article discusses effective JavaScript debugging using browser developer tools, focusing on setting breakpoints, using the console, and analyzing performance.

How do I use source maps to debug minified JavaScript code? How do I use source maps to debug minified JavaScript code? Mar 18, 2025 pm 03:17 PM

The article explains how to use source maps to debug minified JavaScript by mapping it back to the original code. It discusses enabling source maps, setting breakpoints, and using tools like Chrome DevTools and Webpack.

Getting Started With Chart.js: Pie, Doughnut, and Bubble Charts Getting Started With Chart.js: Pie, Doughnut, and Bubble Charts Mar 15, 2025 am 09:19 AM

This tutorial will explain how to create pie, ring, and bubble charts using Chart.js. Previously, we have learned four chart types of Chart.js: line chart and bar chart (tutorial 2), as well as radar chart and polar region chart (tutorial 3). Create pie and ring charts Pie charts and ring charts are ideal for showing the proportions of a whole that is divided into different parts. For example, a pie chart can be used to show the percentage of male lions, female lions and young lions in a safari, or the percentage of votes that different candidates receive in the election. Pie charts are only suitable for comparing single parameters or datasets. It should be noted that the pie chart cannot draw entities with zero value because the angle of the fan in the pie chart depends on the numerical size of the data point. This means any entity with zero proportion

Who gets paid more Python or JavaScript? Who gets paid more Python or JavaScript? Apr 04, 2025 am 12:09 AM

There is no absolute salary for Python and JavaScript developers, depending on skills and industry needs. 1. Python may be paid more in data science and machine learning. 2. JavaScript has great demand in front-end and full-stack development, and its salary is also considerable. 3. Influencing factors include experience, geographical location, company size and specific skills.

TypeScript for Beginners, Part 2: Basic Data Types TypeScript for Beginners, Part 2: Basic Data Types Mar 19, 2025 am 09:10 AM

Once you have mastered the entry-level TypeScript tutorial, you should be able to write your own code in an IDE that supports TypeScript and compile it into JavaScript. This tutorial will dive into various data types in TypeScript. JavaScript has seven data types: Null, Undefined, Boolean, Number, String, Symbol (introduced by ES6) and Object. TypeScript defines more types on this basis, and this tutorial will cover all of them in detail. Null data type Like JavaScript, null in TypeScript

See all articles