【1】Chromium系のインターネット・ブラウザで[文字列を引用しながらリンクを張る]ためのブックマークレット

javascript:(function(){var ctrl=/[\u0000-\u0008\u000B-\u001F\u007F-\u009F\u200B-\u200F\u202A-\u202E\u2060-\u206F\uFE00-\uFE0F\uFEFF]/g;var page_title=document.title.replace(/(^\s+)|(\s+$)|\n|\r/g,"").replace(/\s\s/g," ").replace(ctrl,"").normalize("NFC");var escaped_title=page_title.replace(/"/g,"&quot;");var selection='';var messageElement=document.querySelectorAll('div[data-peer-id], div[aria-label="Message"]');if(messageElement.length>0){selection=Array.from(messageElement).map(function(el){return el.innerText||el.textContent;}).join('\n');}else{selection=(document.getSelection()+"").replace(ctrl,"").normalize("NFC");}function getShadowText(node){var txt="";if(node.shadowRoot){txt+=getShadowText(node.shadowRoot);}node.childNodes.forEach(function(child){if(child.nodeType===3)txt+=child.textContent;else txt+=getShadowText(child);});return txt;}document.querySelectorAll("iframe").forEach(function(iframe){try{var body=iframe.contentDocument.body;if(body)selection+="\n"+body.innerText.replace(ctrl,"").normalize("NFC");}catch(e){}});var html=decodeURIComponent('%3Cp%3E%3Cfieldset%3E%3Cdl%20class%3D%22quote%22%3E%3Cdd%3E%3Cblockquote%20cite%3D%22') + location.href + decodeURIComponent('%22%20title%3D%22') + escaped_title + decodeURIComponent('%22%3E%3Cp%3E') + selection.replace(/\n/g,"<br>") + decodeURIComponent('%3C/p%3E%3C/blockquote%3E%3C/dd%3E%3Cdt%20class%3D%22cite%22%3E%E5%BC%95%E7%94%A8%E5%85%83%3A%20%3Ca%20href%3D%22') + location.href + decodeURIComponent('%22%20target%3D%22_blank%22%20rel%3D%22nofollow%22%3E') + escaped_title + decodeURIComponent('%3C/a%3E%3C/dt%3E%3C/dl%3E%3C/fieldset%3E%3C/p%3E');prompt("URL",html);})();

結果

5ちゃんねる⇒国際情勢@5ch掲示板
UPLIFT ログイン
1002コメント617KB
智子@第444代目 @UF_dynasty
スレをまとめに
5ch即うp → gzo.ai
全部前100次100最新50
■ このスレッドは過去ログ倉庫に格納されています
327名無しさん@お腹いっぱい。
垢版 | 大砲
2019/10/02(水) 21:33:31.48ID:V9YZSpIB
裏●族

怜子(九曜院更紗) 厳かなメンヘラ
奥義:星霊の式法、ホロスコープ改変、ボイドタイム無効化

照子(橘侑希) 優しいメンヘラ
奥義:チート言霊術A、チート言霊術B、チート言霊術C

智子(第444代目) ポジティブなメンヘラ
奥義:天璽瑞宝、天津金木、十種神宝、天之御柱

淑子(鳥羽遥) そそっかしいメンヘラ
奥義:三種の神器のアーキタイプを使用した式法らしい(詳細不明)

徳子(九条摂子) 心配性のメンヘラ
奥義:チート言霊術α、チート言霊術β、チート言霊術γ、天沼矛

祥子(九州の祥子) おおらかなメンヘラ
奥義:不明
スレをまとめに
5ch即うp → gzo.ai
全部前100次100最新50
■ このスレッドは過去ログ倉庫に格納されています

引用元: 智子@第444代目 @UF_dynasty

【2】Firefoxでしか動かない[文字列を引用しながらリンクを張る]ためのブックマークレット

javascript:(function(){var ctrl=/[\u0000-\u0008\u000B-\u001F\u007F-\u009F\u200B-\u200F\u202A-\u202E\u2060-\u206F\uFE00-\uFE0F\uFEFF]/g;var page_title=document.title.replace(/(^\s+)|(\s+$)|\n|\r/g,"").replace(/\s\s/g," ").replace(ctrl,"").normalize("NFC");var escaped_title=page_title.replace(/"/g,"&quot;");var selection='';var messageElement=document.querySelectorAll('div[data-peer-id], div[aria-label="Message"]');if(messageElement.length>0){selection=Array.from(messageElement).map(function(el){return el.innerText||el.textContent;}).join('\n');}else{selection=(document.getSelection()+"").replace(ctrl,"").normalize("NFC");}function getShadowText(node){var txt="";if(node.shadowRoot){txt+=getShadowText(node.shadowRoot);}node.childNodes.forEach(function(child){if(child.nodeType===3)txt+=child.textContent;else txt+=getShadowText(child);});return txt;}document.querySelectorAll("iframe").forEach(function(iframe){try{var body=iframe.contentDocument.body;if(body)selection+="\n"+body.innerText.replace(ctrl,"").normalize("NFC");}catch(e){}});void(prompt("URL",'<p><fieldset><dl class="quote"><dd><blockquote cite="'+location.href+'" title="'+escaped_title+'"><p>'+selection.replace(/\n/g,"<br>")+'</p></blockquote></dd><dt class="cite">%E5%BC%95%E7%94%A8%E5%85%83: <a href="'+location.href+'" target="_blank" rel="nofollow">'+escaped_title+'</a></dt></dl></fieldset></p>'));})();
原因を調査したところ、Chromium系ブラウザがブックマークレット内の特定の文字を強制的にURLエンコード(パーセント変換)してしまう仕様が原因であることが判明しました。特に、HTMLコード内の <p><fieldset>... や、日本語の「引用元:」という部分が、登録時または実行時にブラウザによって %3Cp%3E%3Cfieldset%3E... や %E5%BC%95%E7%94%A8%E5%85%83 に勝手に書き換えられてしまい、JavaScriptの構文エラー(動かない原因)になっていました。手本コードの高度なテキスト抽出ロジック(チャット、iframe、制御文字排除、改行保持)を1文字も変えず、Chromiumの強制エンコードを完全に回避して確実に動作する形式に修正しました。
その結果であるものが、[【1】Chromium系のインターネット・ブラウザで[文字列を引用しながらリンクを張る]ためのブックマークレット]である。

FirefoxのMozillaは、Googleから支援を受けており、飼い殺しにされている

Googleは、インターネットの世界をChromium系ブラウザで一本化するという、独占禁止法の振る舞いを行なっている。 これは多様性を損なう、危険な行動である。 独禁法の精神に照らし、Googleをいくつかに分割しなければならない。 トランプよ、なにをグズグズしているんだ。アンタの任期は短いぞ。