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
| const params = new URLSearchParams(window.location.search); | |
| if (params.get("q")) { | |
| const trySend = setInterval(() => { | |
| const button = document.querySelector('button[aria-label="Send message"]'); | |
| if (button && !button.disabled) { | |
| button.click(); | |
| clearInterval(trySend); | |
| } | |
| }, 200); | |
| setTimeout(() => clearInterval(trySend), 5000); |
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
| chrome.contextMenus.onClicked.addListener((info) => { | |
| if (info.menuItemId !== "askClaude") return; | |
| const text = `I selected "${info.selectionText}" on my browser\n\nI would normally Google this. Tell me what I need to know.`; | |
| chrome.tabs.create({ url: `https://claude.ai/new?q=${encodeURIComponent(text)}` }); | |
| }); |
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
| { | |
| "manifest_version": 3, | |
| "name": "Ask Claude", | |
| "version": "1.0", | |
| "description": "Right-click selected text to ask Claude", | |
| "permissions": ["contextMenus"], | |
| "background": { | |
| "service_worker": "background.js" | |
| }, | |
| "content_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
| @app.route("/claps", methods=["GET"]) | |
| def get_claps(): | |
| data, _ = get_claps_file() | |
| key = normalise_url(request.args.get("url")) | |
| return jsonify({"claps": data.get(key, 0)}) | |
| @app.route("/claps", methods=["POST"]) | |
| def add_clap(): | |
| data, sha = get_claps_file() | |
| key = normalise_url(request.args.get("url")) |
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
| class RetainDecorator<T : Any>( | |
| retainedValuesStoreRegistry: RetainedValuesStoreRegistry, | |
| ) : NavEntryDecorator<T>( | |
| decorate = { entry -> | |
| logDebug { "Retaining ${entry.contentKey}" } | |
| retainedValuesStoreRegistry.LocalRetainedValuesStoreProvider(entry.contentKey) { | |
| entry.Content() | |
| } | |
| }, |
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
| @Composable | |
| fun GameScreen( | |
| gameViewModel: GameViewModel = viewModel() | |
| ) { | |
| // ... | |
| } |
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
| @Composable | |
| fun FirstScreen() { | |
| val customRetainedViewModel = retain { | |
| CustomRetainedViewModel() | |
| } | |
| val state by customRetainedViewModel.state.collectAsStateWithLifecycle() | |
| // .... | |
| } |
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
| @Composable | |
| fun FirstScreen() { | |
| val customRetainedViewModel = rememberRetainedViewModel<CustomRetainedViewModel>() | |
| val state by customRetainedViewModel.state.collectAsStateWithLifecycle() | |
| // .... rest of the owl | |
| } |
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
| @Composable | |
| inline fun <reified T : RetainedViewModel> rememberRetainedViewModel(noinline factory: (Context) -> T): T { | |
| val context = LocalContext.current | |
| return retain { factory(context) } | |
| } | |
| // ..compose layer | |
| val customRetainedViewModel = rememberRetainedViewModel { context -> | |
| EntryPoints.get(context, CustomRetainedViewModelEntryPoint::class.java).customRetainedViewModel() | |
| } |
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
| @EntryPoint | |
| @InstallIn(ActivityComponent::class) | |
| interface CustomRetainedViewModelEntryPoint : RetainedViewModelEntryPoint<CustomRetainedViewModel> | |
| @RetainedEntryPoint(CustomRetainedViewModelEntryPoint::class) | |
| class CustomRetainedViewModel @Inject constructor( | |
| // ... | |
| ) : RetainedViewModel() { | |
| // ... | |
| } |
NewerOlder