js detects keywords in the title and description and replaces or jumps to other pages when found

js detects keywords in the title and description and replaces or jumps to other pages when found

Keywords General

The title cannot contain words like crack, key, serial number, or keygen. Otherwise, it should be redirected or replaced with other words.

var mflag=false;
var mtit=document.title;
var mcont=document.getElementsByName('description')[0].content;

var arr=['crack','key','serial number','registration machine'];

for(x in arr){
if (encodeURI(tit).indexOf(arr[x]) != -1){
			flag=true;
		}
	if (encodeURI(cont).indexOf(arr[x]) != -1){
			flag=true;
		}
	}
	if(flag){
		/*$('body').html('Sorry, this page has been deleted!').css({
					"font-size": "20px",
					"padding-top": "20px"
				});
		$('html').hide();		
		$('html').text('Sorry, this page has been deleted!');*/
		window.location.href = "https://yourdomain/404.htm";
	}

Keyword Encryption

var mflag=false;
var mtit=document.title;
var mcont=document.getElementsByName('description')[0].content;

var arr=['%E7%A0%B4%E8%A7%A3','key','%E5%BA%8F%E5%88%97%E5%8F%B7','%E7%89%B9%E5%88%AB%E7%89%88'];

for(x in arr){
if (encodeURI(tit).indexOf(arr[x]) != -1){
			flag=true;
		}
	if (encodeURI(cont).indexOf(arr[x]) != -1){
			flag=true;
		}
	}
	if(flag){
		/*$('body').html('Sorry, this page has been deleted!').css({
					"font-size": "20px",
					"padding-top": "20px"
				});
		$('html').hide();		
		$('html').text('Sorry, this page has been deleted!');*/
		window.location.href = "https://yourdomain/404.htm";
	}

That is to say, it increases the difficulty of reading, but the idea is good but it is not easy for others to find it.

Mainly using indexOf and JavaScript encodeURI() function

JavaScript encodeURI() Function

Definition and Usage

The encodeURI() function encodes a string as a URI.

grammar

encodeURI(URI string)

parameter describe
URI string Required. A string containing the URI or other text to be encoded.

Return Value

A copy of URIstring with some characters replaced by hexadecimal escape sequences.

illustrate

This method does not encode ASCII letters and numbers, nor does it encode these ASCII punctuation characters: - _ . ! ~ * ' ( ) .

The purpose of this method is to fully encode the URI, so encodeURI() function will not escape the following ASCII punctuation characters that have special meanings in URIs: ;/?:@&=+$,#

Tips and Notes

Tip: If the URI components contain separators, such as ? and #, you should encode each component separately using the encodeURIComponent() method.

Examples

In this example, we will use encodeURI() to encode the URI:


[Ctrl+A Select all Note: To import external Js, you need to refresh the page to execute it]

Output

%E8%84%9A%E6%9C%AC%E4%B9%8B%E5%AE%B6
www.jb51.net
www.jb51.net/My%20first/
,/?:@&=+$#

This is the end of this article about how to use js to detect keywords in titles and descriptions and replace or jump to other pages. For more relevant js keyword search content, please search previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future!

<<:  Summary of B-tree index knowledge points in MySQL optimization

>>:  Detailed tutorial on using cmake to compile and install mysql under linux

Recommend

VMware vSphere 6.7 (ESXI 6.7) graphic installation steps

Environment: VMware VCSA 6.7 (VMware-VCSA-all-6.7...

Understanding and application scenarios of enumeration types in TypeScript

Table of contents 1. What is 2. Use Numeric Enume...

What command is better for fuzzy searching files in Linux?

1. Introduction This article mainly explains how ...

Introducing icons by implementing custom components based on Vue

Preface In project development, there are many wa...

Detailed explanation of the new background properties in CSS3

Previously, we knew several attributes of backgro...

How many ports can a Linux server open at most?

Table of contents Port-related concepts: Relation...

Some CSS questions you may be asked during an interview

This article is just to commemorate those CSS que...

An article to help you thoroughly understand position calculation in js

Table of contents introduction scroll Element.scr...

How to upgrade https under Nginx

Purchase Certificate You can purchase it from Ali...

CSS to achieve dynamic secondary menu

Dynamically implement a simple secondary menu Whe...

mysql wildcard (sql advanced filtering)

Table of contents First, let's briefly introd...

Basic ideas for finding errors in Web front-end development

WEB development mainly consists of two interactio...

Public free STUN servers

Public free STUN servers When the SIP terminal us...

Example of how to optimize MySQL insert performance

MySQL Performance Optimization MySQL performance ...