Scramble Web Site Images using TamperMonkey Script

// ==UserScript==
// @name         New Userscript
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       euhat
// @match        https://www.sample.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=toutiao.com
// @grant           GM_xmlhttpRequest
// @grant           GM_setValue
// @grant           GM_getValue
// @grant           GM_addStyle
// @grant           GM_setClipboard
// @grant           GM_download
// @require         https://unpkg.com/vue@2
// ==/UserScript==
 
(function() {
	'use strict';
 
	var euForm = document.createElement("div");
	euForm.innerHTML = `
		<div id="euForm">
			<b>Here:</b>
			<button @click="euDownAll">Download All Image</button>
		</div>
	`;
 
 
 
	document.querySelector("html").appendChild(euForm);
 
	GM_addStyle(`
#euForm{
font-size : 15px;
position: fixed;
background-color: rgba(88, 88, 88, 0.9);
color : #FF0000;
text-align : center;
padding: 10px;
z-index : 9999;
border:2px solid black;
}
    `);
 
	document.getElementById("euForm").style.left = (200 || 20) + "px";
	document.getElementById("euForm").style.top = (200 || 100) + "px";
 
	function findAllLinks() {
		const allNodes = document.querySelectorAll('div.pgc-img > img');
		var objList = [];
		var i = 0;
		allNodes.forEach((item) => {
			const obj = {
				id: i++,
				url: item.src
			};
			objList.push(obj);
		});
		return objList;
	}
 
	var vm = new Vue({
		el: '#euForm',
		data: {
			version: "1.0.0",
		},
		methods: {
			async euDownAll() {
				var objList = findAllLinks();
				objList.forEach((item) => {
					const obj = {
						url: item.url,
						name: item.id + ".jpg",
						onload: function(e) {
 
						},
						onerror: function(e) {
							console.log(e)
						},
						onprogress: function(d) {
 
						}
					}
					GM_download(obj)
				});
			},
		}
	});
 
})();

refer to:
https://developer.mozilla.org/zh-CN/docs/Web/API/Document/querySelectorAll

Change Font Size in Win32 Rich Edit Control

	char* strFont = "Open Sans";
	int nFontSize = 70;
 
	CHARFORMAT cfFormat;
	memset(&cfFormat, 0, sizeof(cfFormat));
	cfFormat.cbSize = sizeof(cfFormat);
	cfFormat.dwMask = CFM_CHARSET | CFM_FACE | CFM_SIZE;
	cfFormat.bCharSet = ANSI_CHARSET;
	cfFormat.bPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
	cfFormat.yHeight = (nFontSize * 1440) / 72;
	strcpy(cfFormat.szFaceName, strFont);
 
	CHARRANGE cr;
	cr.cpMin = INT_MAX;
	cr.cpMax = INT_MAX;
	SendDlgItemMessage(m_hWnd, IDE_EDITBOX, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cfFormat);
	SendDlgItemMessage(m_hWnd, IDE_EDITBOX, EM_EXSETSEL, 0, (LPARAM)&cr);

refer to:
https://gamedev.net/forums/topic/457546-rich-edit-controls-change-the-font-size-win32-c/457546/

Change hyperlink color in QT

1
2
3
4
5
6
	// ui->btnEdit is a QLabel.
	ui->btnEdit->setText(QString("<a href=\"localhost\"><font color=\"#ff0000\">") + tr("Edit") + QString("</font></a>"));
	ui->btnEdit->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
	connect(ui->btnEdit, &QLabel::linkActivated, [=, this](QString url) {
		...
	});

refer to:
https://www.lmlphp.com/user/507/article/item/13949

QTimeLine starts very slowly

Need to set the time line execution curve as linear.

1
2
3
4
5
	m_time_line.reset(new QTimeLine(m_span_msecs * count, this));
	m_time_line->setFrameRange(0, count);
	m_time_line->setEasingCurve(QEasingCurve::Linear);
	// below is deprecated
	//m_time_line->setCurveShape(QTimeLine::LinearCurve);

refer to:
http://www.wjhsh.net/rickyk-p-4044875.html

Retrieve all widgets after times of calling addWidget at same position

Don't call QGridLayout::itemAtPosition.

Like this,

1
2
3
4
5
6
7
8
9
10
11
12
for (int i = 0; i < grid_layout->count(); i++)
{
	QLayoutItem* item = grid_layout->itemAt(i);
 
	if (item->widget() == widget_wanted)
	{
		int row, column, row_span, column_span;
		grid_layout->getItemPosition(i, &row, &column, &row_span, &column_span);
 
		// grid_layout->addWidget(frame, row, column);
	}
}

C++ memo

Terms,

1
2
RTTI: Runtime Type Identification		// typeid
RAII: Resource Acquisition Is Initialization	// std::mutex

Blender source memo

1
2
3
4
5
6
7
8
9
10
#blender\source\blender\editors
ED_region_do_draw editors\screen\area.c
	outliner_main_region_draw editors\space_outliner\space_outliner.cc
		draw_outliner editors\space_outliner\outliner_draw.cc
			outliner_buttons
				UI_but_active_only editors\interface\interface.cc
					UI_but_active_only_ex
						ui_but_activate_event editors\interface\interface_handlers.c
							ui_do_button
								ui_do_but_TEX