Last active
January 30, 2023 23:56
-
-
Save anthony1x6000/99808ce4697ebca6b422373f384a04ff to your computer and use it in GitHub Desktop.
Userscript that calls openai with a question, gets an answer, and displays it all within two inputs on the bottom of a website that appear if hovered upon. This is very clearly for cheating on google forms.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Text Completion | |
| // @namespace http://tampermonkey.net/ | |
| // @version 0.2 | |
| // @description textbox and respponse | |
| // @author You | |
| // @match *://*/* | |
| // @grant none | |
| // ==/UserScript== | |
| (async function() { | |
| 'use strict'; | |
| const apiKey = "YOUR_API_KEY"; | |
| const model = "text-davinci-003"; | |
| let prompt; | |
| const textbox = document.createElement("input"); | |
| textbox.type = "text"; | |
| textbox.value = prompt; | |
| textbox.style.bottom = "0"; | |
| textbox.style.width = "10%"; | |
| textbox.style.zIndex = "500"; | |
| textbox.style.position = "fixed"; | |
| textbox.style.opacity = "0"; | |
| document.body.appendChild(textbox); | |
| const output = document.createElement("input"); | |
| output.style.position = "fixed"; | |
| output.style.bottom = "0px"; | |
| output.style.right = "0"; | |
| output.style.width = "80%"; | |
| output.style.margin = "none"; | |
| output.style.padding = "none"; | |
| output.style.backgroundColor = "#fff"; | |
| output.style.zIndex = "9999"; | |
| output.style.opacity = "0"; | |
| document.body.appendChild(output); | |
| let isHidden = false; | |
| document.addEventListener("keydown", function(event) { | |
| if (event.ctrlKey && event.code === "Semicolon") { | |
| isHidden = !isHidden; | |
| if (isHidden) { | |
| textbox.style.opacity = "0"; | |
| output.style.opacity = "0"; | |
| } else { | |
| textbox.style.cursor = "auto"; | |
| output.style.cursor = "auto"; | |
| } | |
| } | |
| }); | |
| textbox.addEventListener("mouseover", function() { | |
| if (!isHidden) { | |
| textbox.style.opacity = "1"; | |
| output.style.opacity = "1"; | |
| } else { | |
| textbox.style.cursor = "default"; | |
| } | |
| }); | |
| textbox.addEventListener("mouseout", function() { | |
| textbox.style.opacity = "0"; | |
| output.style.opacity = "0"; | |
| }); | |
| output.addEventListener("mouseover", function() { | |
| if (!isHidden) { | |
| output.style.opacity = "1"; | |
| } else { | |
| output.style.cursor = "default"; | |
| } | |
| }); | |
| output.addEventListener("mouseout", function() { | |
| output.style.opacity = "0"; | |
| }); | |
| let promptIndex; | |
| let currentIndex = 0; | |
| const prompts = ["SDLC: The SDLC is a series of stages for developing software, including the Waterfall model (5 stages: Requirements, Design, Implementation, Testing, Maintenance), the Iterative model (multiple cycles of requirements, design, testing, and implementation), the V-Shaped model (structured, well-understood requirements with a focus on testing), and the Spiral model (large projects with emphasis on risk analysis and 6 phases: Requirements Analysis, Preliminary Design, Detailed Design, Coding, Model Test, System Test). The Spiral model improves with each iteration revisiting the design phase. Software Development Life Cycle (SDLC) stages: Waterfall (Basic) Model- 5 stages: Requirements Specification (outlines planned features and functionality), Design (plans how software will work using flow chart and designs user interface), Implementation (writes code and tests it), Testing (ensures it meets requirements), Maintenance (ensures software meets user needs). Visualized as sequence, used for small projects. Waterfall Model is just the basic model, but visualized as sequence. Incremental (Iterative) Model- well suited for medium-sized projects, starts with simple implementation, evolves through multiple development cycles, passes through requirements, design, testing, and implementation stages, produces working version in first build. V-Shaped Model- structured, well suited for projects with well understood requirements, but unwieldy for larger scale projects, has stages: Requirements, HLD (high-level design), Detailed specifications, Coding, Testing, each stage completed before next begins, testing given high priority, focuses on risk analysis. Spiral Model- places emphasis on risk analysis, has 6 phases: Requirements Analysis, Preliminary Design, Detailed Design, Coding, Model Test, System Test, revisits design phase in each subsequent spiral, improves on baseline spiral, good for large projects with cost and risk evaluation importance.", | |
| "HARDWARE: The system unit is the main part of a computer system and typically includes the motherboard, central processing unit, internal disk drives, memory, graphics cards, and sound cards. The motherboard is a printed circuit board that connects the other components. The ATX power connector is used to connect the power supply unit to the internal components of the computer. The SATA port is used to connect mass storage devices such as hard drives and optical drives to the motherboard. Ports enable users to connect peripheral devices to the motherboard. PCI and PCIe slots are used to connect expansion cards such as graphics, sound, video, and Network Interface Controller (NIC) cards to the motherboard. Memory slots are used to connect memory modules such as main memory (RAM) to the motherboard. Cache memory stores frequently used instructions and data in a storage area that is close to the CPU. ROM is a type of permanent memory that stores essential data. The CPU is responsible for processing data for all the tasks that a computer performs. A CPU is often referred to as the brain of the computer and is the most important part of a computer. The first CPU chip was invented in 1971, was a 4-bit processor created for a calculator, and all CPUs were originally created with a single core processor. Dual-core processors were developed in the early 2000s and the trend of adding cores, physical and virtual, has continued with newer CPUs such as quad-core, hexa-core, and octa-core. The CPU goes through a cycle of fetching, decoding, and executing instructions in order to perform tasks. Clock speed is the rate at which a CPU operates, measured in hertz. Cache memory is used to improve clock speed by storing frequently used instructions and data closer to the CPU. Different processors have different architectures and instructions that affect the speed at which they can process. Memory is the part of a computer system that stores data for use by the CPU, it can be volatile or non-volatile. RAM provides temporary storage for programs and data while they are running. ROM stores essential data such as a computer's configuration settings. Secondary storage is a form of permanent data storage that is not connected to the CPU or main memory. It is non-volatile, meaning data is retained even when the power supply is turned off. Examples of secondary storage include magnetic storage devices such as hard disk drives (HDD) and solid-state drives (SSD). Magnetic storage devices use different patterns of magnetization to store data and have an average read and write speed of 120MB/s. SSDs use flash memory and have an average read and write speed of 500MB/s. They are more durable and reliable than HDDs but are more expensive. SATA and NVMe are interfaces used for SSDs, with NVMe being the newer and faster protocol. Flash drives and memory cards also use integrated circuit semiconductor chips to store data and are commonly used for data transfer and backups. They are small, lightweight, and durable making them easily portable. Peripherals are hardware devices that connect to the central processing unit (CPU) and provide input, output, and storage capabilities to the computer system. Storage devices are used to record and store data, examples include external hard disk drives, flash drives and optical storage devices such as CDs and DVDs. Input devices send data and control signals to the computer, examples include keyboard, mouse and graphics tablet. These input devices allow the user to interact with the computer and control the cursor on the screen. Peripherals are hardware devices that connect to the central processing unit (CPU) and provide input, output, and storage for the computer system. Storage devices include external hard disk drives (HDD), flash drives, and optical storage devices like CDs and DVDs. Input devices include keyboard, mouse, graphics tablet, touchscreen, scanner, and microphone. Output devices include monitor, printer, speakers, headphones, lights, and projectors. These devices communicate the results of processed data in various forms such as visual, audible, or light signals.", | |
| "NETWORKS: A network is a connection of two or more computers that allow them to share resources and communicate with each other. Networks can be classified by geography (LAN, MAN, SAN, and WAN) and by component roles (peer-to-peer, server-based, and client-based). LANs are for computers located at a single site, MANs are for computers in a metropolitan area, SANs are for storage servers and WANs are for computers in multiple locations. Peer-to-peer networks are equal and no one computer is in charge while server-based networks offer centralized control. Client-based networks have increased capabilities of the client computer. Computer networks are systems of computers connected together to share data and resources, such as printers and software. The components of a computer network include clients, servers, users, resources, communication media, and network adapters. Protocols, such as TCP, IP, HTTP, FTP, and mail protocols, are sets of rules used to communicate between devices on the network. Computers connect to the network through a network interface, using methods such as coaxial cable, fiber-optic cable, twisted pair cable, or radio waves. In network communication, information passes through several layers such as the Application, Presentation, Session, Network, Data-Link and Physical layers to ensure that the data is accurate and intact. The information travel starts at the source and moves through the various layers before reaching the destination. The information then travels through various networks and can be sent directly to the destination if it's within the same geographic area. If not, the information is sent to a Network Access Point (NAP) and can be passed through different components such as repeaters, hubs, bridges, and gateways. The data is also packaged into packets that contain the necessary information for ensuring the request reaches the destination. Network Communication: Receiving Node When a message arrives at the receiving node (destination) the entire process is reversed. Physical layer converts the message into bits. The Data-Link layer recalculates the checksum, confirms arrival, and logs in the packet. Network layer recounts incoming packets for security. Transport layer recalculates the checksum, reassembles the message segments. Session layer holds the parts of each message until it is complete, and sends it to the next layer. Presentation layer decrypts, expands, and translates the message. Application layer identifies the recipient converts bits into characters and sends the data to the appropriate application. A network topology refers to the way in which all network components are connected together. The three common types of network topology are Ring, Star, and Bus. In a Ring Network, devices are connected in a ring formation and is fast with data flowing in one direction but slows down with more users and is not reliable as the whole network breaks down if the central cable fails. In a Star Network, terminals are connected to a central computer called the hub node, which controls the network and stores shared resources, making it expensive but reliable as the network remains unaffected if one connection fails. In a Bus Network, terminals are connected to a single cable and is the simplest network that is cheap to install but slow if serving many terminals, and will break down if the central cable fails. In a home network, devices are connected through either wireless or ethernet and a router is used to connect these devices and access the internet through a DSL or Cable Internet connection. A firewall, which is either hardware or software, is placed between the internet and networked devices and data to filter information and protect from malicious data and software. Firewall rules include Port Limiting, Packet Filtering, Proxy, Stateful Inspection, Alerts, and Security Logs. WiFi is a wireless network governed by the 802.11 standards that use radio waves to communicate between devices and the internet. WiFi networks begin with an access point (AP) and use 2.4GHz or 5GHz bandwidth. The latest standard, 802.11ax, has a speed up to 3.5Gbps, uses both 2.4GHz and 5GHz bands, and allows the router to communicate with multiple devices simultaneously. Ethernet networks are wired networks governed by the 802.3 standards that use CAT5, CAT6, or CAT7 cables. Ethernet networks tend to be more secure and faster than wireless networks, but more expensive and restrict device use to locations close to a connection plate. DSL, or ADSL, is a high-speed connection that uses telephone lines and is distance sensitive. Cable Internet is a form of broadband that uses cable connections to deliver both TV signals and internet access, with more bandwidth allocated for downloads.", | |
| "SECURITY: Low Tech Attack: trying to trick employees into revealing their passwords, and Brute Force Attack: use a program that will use the userids that have been found to login to the system and try all possible password combinations. Most spyware is downloaded unwittingly by users. Spyware tends to be installed into the Program file folder. Some spyware embeds itself into the operating system which makes it much more difficult to find, and remove. Spyware programs can also do anything you, or your computer can do. Ransomware is type of malware that uses extortion based attacks that can result in loss of access to information, confidentiality, and leakage. This is a well-known form of ransomware and can cause a great deal of damage. Scareware often claims to have found issues on your computer, demanding money to resolve them.Ransomware as a Service or RaaS is a type of malware hosted anonymously by a hacker. Doxware threatens to publish your stolen information online if you dont pay the ransom. Backup files allow victims to restore their files once the infection has been cleaned up. A virus is created when a programmer deliberately infects a program with code (software) that is able to duplicate, obscure itself from detection, monitor events on your system (time or actions), and to react to these events. Some viruses copy themselves into memory where they can check for the trigger event and monitor antivirus software. Email viruses can take on different forms depending on the type of virus. Attachment viruses are the most common form of email viruses. HTML viruses are much more difficult to detect, or defend against. MIME viruses exploit a hole in some browsers/email applications. Antivirus SW will inspect the master boot record, program files, and macro code to check for viruses. It also installs itself into RAM to operate in the background where it monitors the computers operations for suspicious activity. The firewall will inspect each outbound packet to determine if the internet address is to a banned location. Personal data is worth more than oil in the world economies. Firewalls compare the parts of the packets to a database containing safe data using stateful inspection. If the data inside of each packet must be similar to data that the firewall has previously seen, it is sent to the destination if not it is discarded. It works by analyzing the content of an email message and comparing it to a database of known spammers terms and phrases. The most effective tools for detecting spam are Bayesian filters and content filters. Most Anti-Spam software will use a peer-to-peer technique where the blacklist, and whitelists are shared and updated either on centralized servers, or widely distributed through background programs. A VPN is an encrypted tunnel on the internet from your computer to a VPN server. Stuxnet is thought to be responsible for causing substantial damage to Irans nuclear program. Encryption is used to ensure that the information that you are sending and receiving between two computers is not read by others.", | |
| "ALGORITHMS: An algorithm is a sequence of instructions used to solve a problem. Algorithms can be created using a system flowchart, pseudocode or both. The system flow chart or pseudo code must be converted into a programming language before it can be used to perform tasks on a computer. An iteration is required when a series of instructions needs to be repeated until the desired answer is achieved. A set of instructions that is repeatedly executed is know as a loop. There are three types of loops - FOR, REPEAT, and WHILE - depending on the condition.In Java Subroutines and Methods are broken down into 2 distinct groups, those that return a single value (Functions) and those that do not (Procedures). These terms are gradually falling from use, but the ability to distinguish the types is important. To create a procedure, first define it and give it a name that describes its' purpose. A function computes a value using data provided by the program and returns a single value. This function will print the value resulting from the addition of 6 + 4, or 10.Terminators, which are shaped like an oval, indicate where the process starts and finishes. Inputs, which are shaped like a parallelogram, represent a process input, such as student id, or other details. Decisions, which are shaped like a rhombus, pose a question and have different routes out for different answers. Processes, which are shaped like a rectangle, are actions to be performed. A process always includes a verb.", | |
| "PROTOTYPING: Prototyping is a method used to develop software, where a simple version of the program is created to demonstrate how the system will work. The two main approaches are Evolutionary and Throwaway. Evolutionary involves continually refining the prototype until the user is satisfied, while Throwaway discards the prototype after incorporating user feedback into the final product. Advantages include ensuring software requirements are met, improved quality, user involvement, cost-effectiveness, and early training. Disadvantages include neglect of other parts of the system, user attachment to the prototype, development time and hardware cost, delay, and developer attachment." | |
| ]; | |
| document.addEventListener("keydown", (event) => { | |
| if (event.key === "ArrowUp") { | |
| promptIndex = (promptIndex + 1) % prompts.length; | |
| textbox.value = prompts[promptIndex] + "Question: "; | |
| } else if (event.key === "ArrowDown") { | |
| promptIndex = (promptIndex - 1 + prompts.length) % prompts.length; | |
| textbox.value = prompts[promptIndex] + "Question: "; | |
| } | |
| }); | |
| promptIndex = 0; | |
| const fetchCompletion = async () => { | |
| if (event.key !== 'Enter') return; | |
| const response = await fetch("https://api.openai.com/v1/completions", { | |
| method: "POST", | |
| headers: { | |
| "Content-Type": "application/json", | |
| "Authorization": `Bearer ${apiKey}` | |
| }, | |
| body: JSON.stringify({ | |
| model, | |
| prompt: textbox.value, | |
| max_tokens: 256, | |
| top_p: 1, | |
| temperature: 0, | |
| frequency_penalty: 0, | |
| presence_penalty: 0, | |
| }) | |
| }); | |
| const json = await response.json(); | |
| console.log(json); | |
| output.value = json.choices[0].text; | |
| }; | |
| textbox.addEventListener("keyup", fetchCompletion); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment