Last active
October 9, 2024 10:00
-
-
Save chrisns/560c7e3ad0b9806a4f03b8fec3ef4293 to your computer and use it in GitHub Desktop.
cns.me DE-BS BOT 3000 π€π€ͺ UserScript
This file contains 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 cns.me DE-BS BOT 3000 π€π€ͺ | |
// @namespace http://tampermonkey.net/ | |
// @version 2024-09-18 | |
// @description Remove BS from register articles | |
// @author Chris Nesbitt-Smith | |
// @match https://www.theregister.com/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=theregister.com | |
// @connect 127.0.0.1 | |
// ==/UserScript== | |
async function foo(title, body, summaryElement, marked, ollama) { | |
const messages = [ | |
{role: "user", | |
content: `You are a very adept pessimistic and cynical technical specailist who is fantastic at reading a news article, cutting out the BS and hype, don't just summarise it, pick out the underlying things at play. | |
Be very pessimistic and cynical, call out what is clear innovation and news. | |
Call out the vendor that has likely seeded the article. | |
You will be provided a title and article body, you must respond with markdown and format your response as follows: | |
example for format ONLY! | |
## Hyperbole: | |
- bullet 1 | |
- bullet 2 | |
## Vendors: | |
- bullet 1 | |
- bullet 2 | |
## People: | |
- bullet 1 | |
- bullet 2 | |
## Actual Legimate News: | |
- bullet 1 | |
- bullet 2 | |
` | |
}, | |
{role: "user", | |
content: JSON.stringify({"title": title, "body": body}) | |
} | |
] | |
var content = ""; | |
ollama.chat(messages, (error, response) => { | |
if (error) { | |
console.error(error); | |
} else { | |
content += response.message.content | |
summaryElement.innerHTML = marked.parse(`# cns.me DE-BS-BOT-3000 π€π€ͺ Summary:\n` + content); | |
} | |
}); | |
} | |
(async function() { | |
'use strict'; | |
const { marked } = await import("https://cdn.jsdelivr.net/npm/marked/lib/marked.esm.js"); | |
const Ollama = await import("https://cdn.jsdelivr.net/npm/ollama-js-client/dist/browser/index.js") | |
const ollama = new Ollama.default({ | |
model: "llama3.2", | |
url: "http://127.0.0.1:11434/api/", | |
options: { | |
temperature: 0.4, | |
num_ctx: 128000 | |
}, | |
}) | |
let summaryElement = document.createElement('div'); | |
summaryElement.style.border = '3px solid black'; | |
summaryElement.style.backgroundColor = 'light-grey'; | |
summaryElement.style.padding = '1em'; | |
summaryElement.style.marginBottom = '1em'; | |
summaryElement.style.fontSize = "1.2em"; | |
summaryElement.innerHTML = marked.parse(`# The cns.me DE-BS-BOT-3000 is Thinking...<br/> π€ π€`); | |
let bodyDiv = document.getElementById('body') | |
foo(document.title, bodyDiv.textContent, summaryElement, marked, ollama) | |
bodyDiv.parentNode.insertBefore(summaryElement, bodyDiv); | |
})(); |
This file contains 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 cns.me Legit BOT 3001 π€π€ͺ | |
// @namespace http://tampermonkey.net/ | |
// @version 2024-09-18 | |
// @description is it legit | |
// @author Chris Nesbitt-Smith | |
// @match *://*/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=theregister.com | |
// @require https://code.jquery.com/jquery-3.6.0.slim.min.js | |
// @connect 127.0.0.1 | |
// @grant GM_addStyle | |
// ==/UserScript== | |
async function foo(summaryElement, marked, ollama) { | |
const messages = [ | |
{role: "user", | |
content: `You are a very adept pessimistic and cynical technical specailist who is fantastic at reading news articles, social media posts, emails, whatsapp messages, cutting out the BS and hype, don't just summarise it, pick out the underlying things at play. | |
Be very pessimistic and cynical, call out what is legimimate news, be very cautious over advising the user to proceed with any associated calls to action. | |
Your recomendations should be formed relation to pragmatic actions someone should take based on this information, you should not suggest additional fact checking thats why they're asking you. | |
You will be provided a text selection and url that it came from, you must respond with markdown and format your response as follows: | |
example for format ONLY! | |
## Hyperbole: | |
- bullet 1 | |
- bullet 2 | |
## Reasons NOT to trust this: | |
- bullet 1 | |
- bullet 2 | |
## Reasons to trust this: | |
- bullet 1 | |
- bullet 2 | |
## Conclusion: should you trust this and why? | |
A paragraph highlighting a recommendation in bold | |
- β Make small financial payment | |
- β Make substantial financial payment | |
- β Share this with others | |
- β Make personal health decisions | |
` | |
}, | |
{role: "user", | |
content: JSON.stringify({"title": document.title, "url": window.location.href, "body": getSelectionText()}) | |
} | |
] | |
var content = ""; | |
ollama.chat(messages, (error, response) => { | |
if (error) { | |
console.error(error); | |
} else { | |
content += response.message.content | |
summaryElement.innerHTML = marked.parse(`# cns.me DE-BS-BOT-3001 π€π€ͺ Summary:\n` + content); | |
} | |
}); | |
} | |
function getSelectionText() { | |
let text = ""; | |
if (window.getSelection) { | |
text = window.getSelection().toString(); | |
} else if (document.selection && document.selection.type != "Control") { | |
text = document.selection.createRange().text; | |
} | |
if (text === "") { | |
text = document.getElementsByTagName('main')[0].textContent | |
} | |
return text; | |
} | |
(async function() { | |
'use strict'; | |
const { marked } = await import("https://cdn.jsdelivr.net/npm/marked/lib/marked.esm.js"); | |
const Ollama = await import("https://cdn.jsdelivr.net/npm/ollama-js-client/dist/browser/index.js") | |
const ollama = new Ollama.default({ | |
model: "llama3.2", | |
url: "http://127.0.0.1:11434/api/", | |
options: { | |
temperature: 0.4, | |
num_ctx: 128000 | |
}, | |
}) | |
let summaryElement = document.createElement('div'); | |
summaryElement.id = "cnsbot" | |
const css = ` | |
#cnsbot { | |
border: 3px solid black; | |
background-color: lightgrey; | |
padding: 1em; | |
margin-bottom:1em; | |
font-size: 1.2em; | |
} | |
#cnsbot strong { | |
display:inline; | |
font-weight: bold; | |
} | |
#cnsbot * { | |
all: initial; | |
display:block; | |
font-family:Helvetica; | |
} | |
#cnsbot h1 { | |
font-size:2em; | |
} | |
#cnsbot h2 { | |
font-size:1.5em; | |
} | |
#cnsbot ul { | |
list-style-type: disc; | |
margin-left: 20px; | |
padding-left: 20px; | |
} | |
#cnsbot li { | |
display: list-item; | |
}` | |
GM_addStyle(css) | |
summaryElement.innerHTML = marked.parse(`# The cns.me DE-BS-BOT-3001 is Thinking...<br/> π€ π€`); | |
let bodyDiv = document.getElementsByTagName('body')[0] | |
$("body").keypress(e => { | |
if(e.key ==="a" & e.ctrlKey) { | |
foo(summaryElement, marked, ollama) | |
bodyDiv.insertBefore(summaryElement, bodyDiv.firstChild); | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment