Skip to content

Instantly share code, notes, and snippets.

View magasine's full-sized avatar

Manoel Garcia da Silveira Neto magasine

View GitHub Profile
@magasine
magasine / citationToolFetch.min.js
Last active May 21, 2025 20:49
! Citation Tool - by @magasine #remoteUpdate
javascript:(()%3D%3E%7B!function()%7Bconst%20e%3D%7Bname%3A%22Citation%20Tool%22%2Ccredits%3A%22by%20%40magasine%22%7D%2Ct%3D%7Bid%3A%225d43e4a38323880f34a1da6e7c96ad0e%22%2Cuser%3A%22magasine%22%2Cfilename%3A%22citationTool.js%22%7D%2Co%3D%60gist-cache-%24%7B%22citation-tool%22%7D%60%2Ca%3Dwindow.trustedTypes%3F.createPolicy%3F.(%22citationToolPolicy%22%2C%7BcreateScript%3Ae%3D%3Ee%7D)%3Bfunction%20n(e)%7Bconst%20t%3Ddocument.createElement(%22script%22)%3Bt.type%3D%22text%2Fjavascript%22%3Bconst%20o%3Da%3Fa.createScript(e)%3Ae%3Bt.textContent%3Do%2Cdocument.documentElement.appendChild(t)%2Ct.remove()%7Dconst%20c%3D%60https%3A%2F%2Fgist.githubusercontent.com%2F%24%7Bt.user%7D%2F%24%7Bt.id%7D%2Fraw%2F%24%7Bt.filename%7D%60%3Bfetch(c).then((e%3D%3E%7Bif(!e.ok)throw%20new%20Error(%22Falha%20ao%20buscar%20c%C3%B3digo.%22)%3Breturn%20e.text()%7D)).then((t%3D%3Efunction(t%2Ca%3D%22remote%22)%7BlocalStorage.setItem(o%2CJSON.stringify(%7Bcode%3At%2Ctimestamp%3ADate.now()%7D))%2Cconsole.info(%60%5B%24%7Be.name%7D%5D%2
@magasine
magasine / citationTool.js
Last active May 26, 2025 21:31
Citation Tool - v20250526 - shadow DOM, trusted types, mobile
javascript: (() => {
// Configurações e constantes
const CONFIG = {
BADGE_ID: "citation-tool",
HOST_ID: "citation-tool-host",
APP_INFO: {
name: "Citation Tool",
version: "v20250526", // sanitize function simplified
credits: "by @magasine",
},
@magasine
magasine / waCopyReferenceTo.js
Last active December 21, 2024 20:46
! Whatsapp, Copy reference to
javascript: (function () {
const getSelectedTextWithBreaks = () => {
const selection = window.getSelection();
if (!selection.rangeCount) return "";
const range = selection.getRangeAt(0);
const container = document.createElement("div");
container.appendChild(range.cloneContents());
container.querySelectorAll("br").forEach((br) => br.replaceWith("\n\n"));
@magasine
magasine / textFragmentToPostOnTwitter.js
Last active September 26, 2023 01:27
Text fragment to post on twitter - Bookmarklet
(async () => {
const selectedText = document.title + '\n...\n"' + getSelection().toString() + '"\n...';
const newUrl = new URL(location);
newUrl.hash = `:~:text=${encodeURIComponent(selectedText)}`;
const tweetText = encodeURIComponent(selectedText);
const tweetUrl = encodeURIComponent(newUrl);
const twitterUrl = `https://twitter.com/intent/tweet?text=${tweetText}&url=${tweetUrl}`;
@magasine
magasine / datasSemaforo.js
Created February 19, 2023 19:47
! Datas, Semáforo de (v20230219) - bookmarklet
(function () {
var datePattern = /(\d{2})\/(\d{2})\/(\d{4})/;
var today = new Date();
var dateNodes = [];
function isToday(date) {
var now = new Date();
return date.getDate() === now.getDate() &&
date.getMonth() === now.getMonth() &&
date.getFullYear() === now.getFullYear();
@magasine
magasine / destacaAgContrato.js
Last active February 19, 2023 13:21
Destaca Ag-Contrato v20230219 (bookmarklet)
javascript: (function () {
var pattern = /(?<=\s|^)(?<gSR>\d{2})([\.\/\s-])?(?<gAG>\d{1,4})([\.\/\s-])?(?<gOP>\d{3})([\.\/\s-])?(?<gCONTRATO>\d{1,7})([\.\/\s-])?(?<gDV>\d{2})(?=\s|$)/g;
var textNodes = [];
function recurse(node) {
if (node.nodeType === Node.TEXT_NODE) {
textNodes.push(node);
} else {
for (var i = 0; i < node.childNodes.length; i++) {
@magasine
magasine / scrollToHighlights.js
Last active December 23, 2022 05:15
! Scroll to highlights - Toggle (bookmarklet)
javascript: (function () {
let vCounter = 0;
let objAnchors = {};
let popup;
let popupStyle = `<style>
#id_popup:hover {
border: 2px solid red;
}
#id_popup {
background-color: yellow !important;
@magasine
magasine / saveLoadScrollPositionToggle.js
Last active October 13, 2022 00:35
! Save-Load Scroll Position Toggle (bookmarklet)
javascript: (function () {
if (!localStorage.getItem("position")) {
localStorage.setItem("position", document.documentElement.scrollTop);
target = prompt('Saved positon at: ' + localStorage.getItem("position") + '\nDefine a tag: ', '#yourTagName');
} else {
scrollTo(0, localStorage.getItem("position"));
alert('Go to load "' + target + '" at scroll position: ' + localStorage.getItem("position"));
localStorage.removeItem("position");
}
})();
@magasine
magasine / gistMarkletDirectLink.js
Last active October 7, 2022 17:55
! GistMarklet direct link (bookmarklet)
@magasine
magasine / scrollLeftOrRightToggle.js
Last active November 12, 2022 02:27
! Scroll Left or Right - Toggle (bookmarklet)
javascript : void(function () {
if ((window.innerWidth + window.scrollX) >= document.body.scrollWidth) {
window.scroll(0, 0);
} else {
window.scrollTo(document.documentElement.scrollWidth, 0);
}
})();