Skip to content

Instantly share code, notes, and snippets.

View richie5um's full-sized avatar

Rich Somerfield richie5um

View GitHub Profile
@richie5um
richie5um / worker.js
Created September 3, 2020 12:59
Cloudflare Worker that'll; add a CSP, add a nonce (CSP) for in-line script elements (if they have the 'nonce' attribute), handle Angular 404 status responses. To get the auto-nonce to work, set the inline script in your .html files to be like `<script nonce>console.log('Hello');</script>`.
const cspConfig = {
"default-src": [
"'self'",
"blob:",
],
"script-src": [
"'self'",
"{{cspNonce}}",
],
"style-src": [
name: Smz-CustomXml-v4
description: ''
host: WORD
api_set: {}
script:
content: |
OfficeExtension.config.extendedErrorLogging = true;
$("#get-xml").click(() =>
tryCatch(() => {
name: Smz-GetDocx-CreateDocx
description: ''
host: WORD
api_set: {}
script:
content: >
$("#run").click(() => tryCatch(getDocumentAsCompressed));
// async function run() {
name: Smz-BasicComment (doesn't include selection)
description: ''
host: WORD
api_set: {}
script:
content: |
$("#run").click(() => tryCatch(run));
async function run() {
await Word.run(async (context) => {
@richie5um
richie5um / Smz-CommentRemoval.WORD.yaml
Created August 22, 2022 09:15
Create a new snippet from a blank template.
name: Smz-CommentRemoval
description: Create a new snippet from a blank template.
host: WORD
api_set: {}
script:
content: |
$("#run").click(() => tryCatch(run));
async function removeCommentsFromXML(xmlString) {
let xmlText = "";
name: Smz-CustomXml-v3
description: ''
host: WORD
api_set: {}
script:
content: |
$("#get-xml").click(() =>
tryCatch(() => {
getCustomJson();
})
name: Comments (Ooxml)
description: ''
host: WORD
api_set: {}
script:
content: |
$("#run").click(() => tryCatch(insertComment));
$("#get").click(() => tryCatch(getOoxml));
$("#set").click(() => tryCatch(setOoxml));
name: Comments (Ooxml)
description: ''
host: WORD
api_set: {}
script:
content: >
$("#run").click(() => tryCatch(insertComment2));
// async function insertComment3() {
name: Smz-CustomXml-v3
description: ''
host: WORD
api_set: {}
script:
content: |
$("#get-xml").click(() =>
tryCatch(() => {
getCustomJson();
})
name: Smz-CustomXml-v2
description: ''
host: WORD
api_set: {}
script:
content: |
$("#get-xml").click(() =>
tryCatch(() => {
getCustomJson();
})