Last active
December 22, 2024 14:27
-
-
Save vighnesh153/ca0d404ccc5e04a80bfa9cc34f843d2b to your computer and use it in GitHub Desktop.
Tampermonkey Scripts
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 Disable "Alt/Option + Click" shortcut | |
| // @namespace https://vighnesh153.dev/ | |
| // @version 2024-08-08 | |
| // @description Disables "Alt/Option + Click" shortcut combo that downloads the link on Chrome | |
| // @author vighnesh153 | |
| // @match *://*/* | |
| // @icon https://raw.githubusercontent.com/vighnesh153/vighnesh153-monorepo/main/nodejs-tools/nodejs-chrome-extensions/disable-alt-click-download/images/logo_48x48.png | |
| // @grant none | |
| // @downloadURL https://update.greasyfork.org/scripts/503012/Disable%20%22AltOption%20%2B%20Click%22%20shortcut.user.js | |
| // @updateURL https://update.greasyfork.org/scripts/503012/Disable%20%22AltOption%20%2B%20Click%22%20shortcut.meta.js | |
| // ==/UserScript== | |
| (function () { | |
| 'use strict'; | |
| document.addEventListener('click', (e) => { | |
| // not clicked on anchor tag | |
| const closestAnchor = e.target?.closest('a'); | |
| if (!closestAnchor) { | |
| return; | |
| } | |
| // not clicked on alt or option key | |
| if (!e.altKey) { | |
| return; | |
| } | |
| // disable the "alt/option + click" download shortcut combo | |
| e.preventDefault(); | |
| console.log(`Disabled "alt/option + click" download shortcut combo for link: ${closestAnchor.innerText}`); | |
| }); | |
| })(); |
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 Hide Youtube Paid Content Overlay | |
| // @namespace Violentmonkey Scripts | |
| // @match https://www.youtube.com/* | |
| // @grant none | |
| // @version 1.0 | |
| // @author - | |
| // @description 11/27/2024, 10:57:25 AM | |
| // ==/UserScript== | |
| const styles = ` | |
| <style> | |
| .YtmPaidContentOverlay { | |
| display: none !important; | |
| } | |
| </style> | |
| ` | |
| document.body += styles |
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 LinkedIn QueensGame solution | |
| // @namespace dev.vighnesh153 | |
| // @match https://www.linkedin.com/games/queens/* | |
| // @grant none | |
| // @version 5.0 | |
| // @author - | |
| // @description 12/14/2024, 4:58:56 PM | |
| // ==/UserScript== | |
| function solveQueens() { | |
| // const board = [ | |
| // [c(0), c(0), c(1), c(1), c(1), c(2), c(2), c(2), c(2)], | |
| // [c(0), c(3), c(3), c(3), c(1), c(2), c(1), c(4), c(2)], | |
| // [c(0), c(0), c(0), c(3), c(1), c(1), c(1), c(4), c(2)], | |
| // [c(5), c(6), c(6), c(3), c(3), c(3), c(8), c(4), c(2)], | |
| // [c(5), c(6), c(7), c(7), c(7), c(3), c(8), c(4), c(2)], | |
| // [c(5), c(6), c(7), c(8), c(3), c(3), c(8), c(4), c(2)], | |
| // [c(5), c(6), c(7), c(8), c(8), c(8), c(8), c(4), c(2)], | |
| // [c(4), c(6), c(4), c(4), c(4), c(4), c(4), c(4), c(2)], | |
| // [c(4), c(4), c(4), c(2), c(2), c(2), c(2), c(2), c(2)], | |
| // ]; | |
| const board = parseBoard() | |
| const game = new QueensGame(board) | |
| game.solve() | |
| console.clear() | |
| console.log(board.map((row) => row.map((cell) => cell.value))) | |
| game.logBoard() | |
| } | |
| /** @return {Cell[][]} */ | |
| function parseBoard() { | |
| const grid = document.querySelector("#queens-grid") | |
| const cells = Array.from(grid.children) | |
| const queensCount = Math.floor(Math.sqrt(cells.length)) | |
| const board = [] | |
| let index = 0 | |
| for (let row = 0; row < queensCount; row++) { | |
| const boardRow = [] | |
| for (let col = 0; col < queensCount; col++) { | |
| const cell = cells[index++] | |
| const relevantClass = Array.from(cell.classList).find( | |
| (c) => c.startsWith("cell-color-")) | |
| if (!relevantClass) { | |
| throw new Error("Couldn't find relevant class...") | |
| } | |
| const region = +relevantClass.split("cell-color-")[1] | |
| boardRow.push(c(region)) | |
| } | |
| board.push(boardRow) | |
| } | |
| return board | |
| } | |
| /** | |
| * @param {number} v | |
| * @returns {Cell} | |
| */ | |
| function c(v) { | |
| const cell = new Cell(); | |
| cell.value = v; | |
| return cell | |
| } | |
| class Cell { | |
| isQueen = false; | |
| value = -1 | |
| } | |
| class QueensGame { | |
| /** @param board {Cell[][]} */ | |
| constructor(board) { | |
| this.board = board | |
| this.queensCount = board.length | |
| this.visitedCols = {} | |
| this.visitedRegions = {} | |
| } | |
| /** | |
| * | |
| * @param row {number} | |
| * @param bannedIndices {Array<string>} | |
| * @return {boolean} | |
| */ | |
| solve(row = 0, bannedIndices = []) { | |
| if (row === this.queensCount) { | |
| return this.#isValid() | |
| } | |
| for (let col = 0; col < this.queensCount; col++) { | |
| const cell = this.board[row][col] | |
| if (this.visitedRegions[cell.value] || this.visitedCols[col] | |
| || bannedIndices.includes(row + "," + col)) { | |
| continue | |
| } | |
| cell.isQueen = true | |
| this.visitedRegions[cell.value] = true | |
| this.visitedCols[col] = true | |
| if (this.solve(row + 1, | |
| [ | |
| ...bannedIndices, | |
| // diagonal indices on next row | |
| `${row + 1},${col - 1}`, | |
| `${row + 1},${col + 1}` | |
| ])) { | |
| return true | |
| } | |
| this.visitedRegions[cell.value] = false | |
| this.visitedCols[col] = false | |
| cell.isQueen = false | |
| } | |
| return false | |
| } | |
| logBoard() { | |
| console.log("solution...") | |
| for (const row of this.board) { | |
| const serializedRow = row.map((cell) => cell.isQueen ? "Q" : "_").join( | |
| " "); | |
| console.log(serializedRow); | |
| } | |
| console.log(); | |
| } | |
| #isValid() { | |
| const actualQueensCount = this.board.flatMap((row) => row).reduce( | |
| (acc, cell) => acc + (cell.isQueen ? 1 : 0), | |
| 0, | |
| ); | |
| return this.queensCount === actualQueensCount; | |
| } | |
| } | |
| const queensInterval = setInterval(() => { | |
| try { | |
| solveQueens() | |
| } catch (e) { | |
| console.log("Board not ready", e) | |
| } | |
| }, 1000); | |
| setTimeout(() => { | |
| clearInterval(queensInterval) | |
| }, 10_000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment